Link to home
Start Free TrialLog in
Avatar of charlespliler
charlesplilerFlag for United States of America

asked on

Batch file version of "on error resume nest"

I have a batch file to copy logs from single servers to a shared loaction. It seems that if any of the files in the source directory are locked or in use the whole batch file command set fails and issues and exit code of 4. Is ther a line to add to tell the commands if there is an error with any of the files to copy to just move on to the next. Batch file is as follows.

@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
mkdir "\\usmoksc5app55\text\usmoksc5app27\%dir%"
xcopy /L "D:\GCTI\Logs\*.*" >  "\\usmoksc5app55\text\usmoksc5app27\%dir%\%date:/=-% %T::=%.log"

xcopy /s /c /y "D:\GCTI\Logs\ksc_sip_pri\Archive\*.*" "\\usmoksc5app55\logs\usmoksc5app27\%dir%\"
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

You could put these in your code.
on error goto

Here's a sample - http://newton.freehostia.com/net/batch/batguide.html
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I also use robocopy amd set it for 1 retry in 1 second. This basically just skips files that don't exist.