1.

Solve : Dump errors from a batchscript in a log-file?

Answer»

Hello everyone,

For my work I made a little batchscript for file-renaming.
It looks like this:

@echo off
echo.
For /f "tokens=1,*" %%x in (lijst.txt) do @ren %%y %%x.*


This script uses a .txt file with 2 columns in it, the 1st column CONTAINS the new FILENAME and the 2nd column contains the old filename including the full path and extension and looks like this:

newname1 c:\test\oldname1.jpg
newname2 c:\test\oldname2.jpg
newname3 c:\test\oldname3.jpg

When I run my script and it tries to rename the file oldname3.jpg, but can't find the file in the DIRECTORY it comes up with the on-screen message "The system cannot find the file", but I would like to extend the script so it creates an error log-file so I can see WHICH FILES are not renamed because the script cannot find them.

I tried a lot of options with the "IF EXIST" option and command line parameters like "renamer.bat >>good.log 2>>error.log" or "renamer.bat temp >> %log% 2>&1" but it didn't work out.

I would like an error-log that looks something like this, so I can easily see what went wrong and with what files:


oldname3.jpg
oldname8.jpg
oldname12.jpg


Can somebody help me to adjust my script so it creates an error log that contains the filenames that are not found by the script in the directory?


Regards,

Molski
p.s. My English is "not all that", so I hope people will understand what I mean how about removing the "@echo off" statement?If I do that, or change it to "@echo on" then I STILL get (only) the message, "The system cannot find the specified file".

And I would like to know, what files it cannot find Please do not double post. This was answered in the Programming Section.

Cheesh :-/Okay, excuse me



Discussion

No Comment Found