19 gennaio 2013

Check if a file or folder exists with dos command

You can use the IF EXIST statement to check for the presence of a file or directory:

To check if the file "file.exe" exists in the directory temp:
IF EXIST c:\temp\file.exe ECHO File exists!
 
To check if a the directory "temp" exists (Notice the nul):
IF EXIST c:\temp\nul ECHO Directory exists! 
 
Regards

Nessun commento: