To check if a file exists:
To check if a directory exists (Notice the nul):IF EXIST c:\windows\win.com ECHO File exists!
Note if working with long directory names with spaces, then one needs to put quotes around the directory-/file-path (Notice that nul should not be included):IF EXIST c:\windows\nul ECHO Directory exists!
More Info MS KB65994IF EXIST "C:\Program Files\" ECHO Directory exists!
This "\NUL" folder syntax is not working for me on XPsp2.
OK, further searching seems to indicate the “\NUL” folder syntax only works on FAT drives so it can't be depended upon.
Frank wrote:
I have just tested that one could use the NUL syntax in WinXP on a NTFS drive (and it works).
The problem with the NUL syntax is that one cannot use it with long directory names. I have now updated this very old DOS tip :)
Works on NTFS. My batch file is as follow:
@echo off
IF EXIST "%userprofile%\Local Settings\Application Data\Microsoft\Office\" ECHO Directory exists!
Thanks for the post & tips, Snakefoot
Really usefull. Good job.
Thanks.
Thanks for posting this info , very helpfull
Very useful, thanks for sharing