The syntax of the DOS EXIST statement is:
IF [NOT] EXIST filename command [ELSE expression]
File Examples:
if exist file.txt del file.txt
if exist "long file.txt" del "long file.txt"
if exist file.txt (
echo found
del file.txt
)
Directory Examples:
if exist directory rmdir /s /q directory
if exist "long directory" rmdir /s /q "long directory"
if exist directory (
echo found
rmdir /s /q directory
)