1.

Solve : How to create log of "echo" in batch file??

Answer»

I've got a large batch file that is going to delete several hundred thounsand files from my network. I would like to LOG the "echo" message that either confirms that the file was deleted or states that the file coulnd't be found. How can I do that? My file currently looks like this:
DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif"

Thanks very much for any assistance!!
MelanieIf you want it to just save everything to a file WITHOUT OUTPUT to the screen, you can redirect the batch file output to a file. If your batch file is called mybatch.bat, try:
mybatch.bat >batchlog.txt
When the batch file has completed the RESULTS should be in the batchlog.txt (or whatever file you specify after the > sign). If you want to save it to a file AND the screen then the program(s) being run need to have a switch to be able to do that, or you will have to use an external program, like TEE.EXE.Thanks, Gary, but that doesn't quite accomplish what I want. The log file only contains the list of the files from the batch file but doesn't tell me if the deletion was successfull or not:
C:\Documents and Settings\mwhite>DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif"

Is there a way to get the "1 file deleted" message PRINTED in that file?

MelanieHi, Melanie. I would probably edit the batch file to record your output for that situation. With several hundred thousand files, I would guess that all the file names are not hard coded, are they? Or if they are, there must have been an automated process to fill in the batch file. Either way, I would use the same automation to ECHO the file name to a log file and also send the output of the DEL command to the same log file. Example:
echo Deleting "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif" >>batchlog.txt
DEL "N:\GRACO\PLTPROD\Dorel_Vol01\0000\DJG0000001.tif" >>batchlog.txt

If the batch file is hard-coded with all the names, we can also help you with an automated solution for updating your batch file with the logging additions.Quote

Is there a way to get the "1 file deleted" message printed in that file?

erase xxx.yyy >MyLog.txt 2>&1

Try that, that is all the output there is

Mac



Discussion

No Comment Found