Check if a file or folder exists
It can be useful in batch files to know whether a file or folder exists. One can use files as semaphores and for inter proces communication (IPC).
To check if a file exists:
IF EXIST c:\windows\win.com ECHO File exists!
To check if a directory exists (Notice the nul):
IF EXIST c:\windows\nul ECHO Directory 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:\Program Files\” ECHO Directory exists!
More Info MS KB65994