Using the command line shell or batch files (.bat), you can easily check if a single file exists.
1 2 |
if exist c:\myfile.txt echo asdf if not exist c:\myfile2.txt echo bsdf |
Note the example above does not work with directories or drives! (At least, not on older systems like DOS)
The check would always return false.
Instead, append the important keyword “NUL” to the directory.
1 2 |
if exist c:\mydir\nul echo asdf if not exist d:\nul echo bsdf |
This should work in Windows CMD and also in older MS DOS or FreeDOS versions.
Comments