I have to make a script which deletes all the folders and files in the following directories on Windows Server 2008:
D:\frotxy\out\backup\
D:\frotxy\in\backup\
Yesterday I tried executing the script from my Desktop to delete the files in a test folder but unfortunately I had mistaken the path to this folder. What happened was my Desktop files were deleted - ARGHH!
So my question is is there a safer way to do the script and check it before executing it on the server as it is important not to delete some other directory or file from the server :)
This is the script:
set folder="D:\frotxy\out\backup"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
set folder="D:\frotxy\in\backup"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
And where should I place the file containing the script?
I am not into scripts at all so please help!