Error Handling in Batch Script
Hi,
I have a script for deleting files from specific folders -
forfiles /P X:\<path> /D -7 /M *.* /S /C "cmd /C del @path /Q" |
forfiles /P X:\<path> /D -7 /M *.* /S /C "cmd /C del @path /Q"
I need to implement error handling like folder doesn't exist or files not there etc.
Kindly help me to write the same.
Thanks,
Sugata
|
February 18th, 2015 9:29am
there is not much of errorcontrol in batch.
%ERRORLEVEL% will contain the exit code of the last executed command.
Check this on how to use this
February 18th, 2015 9:33am
Don't worry about trying to write code to catch errors and log information. Just use robocopy.
February 18th, 2015 10:26am
Hi Bill,
Thanks for the reply.could you please let me know how it is used? else any good link to follow?
Regards,
Sugata
February 18th, 2015 11:02am
Robocopy is a built-in command.
There is no need to be helpless. You can find information if you search:
http://www.bing.com/search?q=robocopy
Note that this is not a support forum for the robocopy command.
February 18th, 2015 11:11am