How to check if target of a given path is a directory?
Say:
rem all these should work (by X: I mean a mapped UNC path)
set somepath=some\path
set somepath=c:\some\path
set somepath=x:\some\path
set somepath=\\server\some\path
set isdir=
rem now do some extremely complicated black magic to set %isdir%
if not _%isdir%_==__ (
rem do the directory thing
)
It should work with as most cases as possible from these:
- on Windows NT (i.e. not a Vista+ thing).
- with UNC paths as well as local paths
- with spaces in path
- with or without trailing backslash at the end
- in case contents are not accessible
In extreme cases like when it can't be told (permissions), the fallback value can be no, it's not a directory.