Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi have written a batch file to delete files and folders of a specified location
all is fine but the issue is that when there is no such F: drive in the machine then
the batch file delete the content of the folder where it has been kept .
Can any one help to modify the batch file and to write a condition to check wether that drive is present or not

My batch file

set folder="F:\PortalViewState"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
Posted

1 solution

Use the IF command to test whether a file or directory exists. Type "help if" at the command prompt for details.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900