![]()
[<<]Message[>>] [<<]Author[>>] [<<]Subject[>>] [<<]Thread[>>]
Number : 3833 Date : 2003-02-24 Author : Garry Deane Subject : Re: Wish List - Log File Naming Size(KB) : 2
--- In xxcopy@yahoogroups.com, "yodaslo " wrote: > Hello J. Merrill, > Thanks for the input. > > Can we get the name of the log file that xxcopy generates > to be this? > 2003-02-22_CopyCtoD_EXITCODE-100.log > > Currently we get > 2003-02-22_CopyCtoD.log > by using > xxcopy c:\ d:\ /clone /oNc:\/$yyyy-mm-dd_$CopyCtoD.log > within the xxcopy command line. > > We do not need to determine errorlevel or exitcode inside > the batch, so all of the "if errorlevel.." stuff doesn't > apply. That's much too sophisticated for us. We're simple > people. > If you want the log file to be renamed with the Exit Code, you're going to need to determine the errorlevel (exit code) returned by Xxcopy. You can do this with "IF ERRORLEVEL n" tests as stated by others or by reading the Exit Code from the log file. Below is a batch file (xxlogren.bat) which will determine the name of the most recent log file, scan the log file to extract the Exit Code then rename the log file with the Exit Code appended to the name. It uses the free utility program LMOD.COM (http://home.mnet- online.de/horst.muc/) to do the file parsing. You would use this like the following: xxcopy f:\ g:\ /clone /oNc:\1bu\/$yyyy-mm-dd_$CopyFtoG.log /yy call xxlogren c:\1bu *CopyFtoG.log xxcopy e:\ f:\ /clone /oNc:\1bu\/$yyyy-mm-dd_$CopyEtoF.log /yy call xxlogren c:\1bu *CopyEtoF.log xxcopy d:\ e:\ /clone /oNc:\1bu\/$yyyy-mm-dd_$CopyDtoE.log /yy call xxlogren c:\1bu *CopyDtoE.log Garry ::================ xxlogren.bat ============================== @echo off :: Batch file to rename an Xxcopy log file with the Error Code :: Call this batch file with the log directory path and a filename mask :: e.g. Call xxlogren.bat c:\xxcopy\logs *xxcopy.log :: The most recent log file matching the filename mask will be renamed :: as [logpath]\[filemask]_Error_nn.log where nn is the Xxcopy Error Code if [%1]==[] goto help if [%2]==[] goto help if not exist %1\%2 goto no_file dir %1\%2 /b/o-d | lmod /L1 /S. set fn=[$1][+]set fx=[$2] > ~xx_set.bat call ~xx_set.bat find "Exit" ~xx_set.bat for %%i in (call del) do %%i ~xx_set.bat if exist %1\%fn%_Error_%xxerr%.%fx% del %1\%fn%_Error_%xxerr%.%fx% echo renaming %1\%fn%.%fx% to %fn%_Error_%xxerr%.%fx% ren %1\%fn%.%fx% %fn%_Error_%xxerr%.%fx% goto :eof :help echo Call this batch with the log file path and filename mask echo e.g. %0 c:\xxcopy\logs\ *xxcopy.log goto :eof :no_file echo Error!! Log file %1\%2 not found goto :eof :eof ::================ end xxlogren.bat ===========================
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.