Strange issue with batch files (Windows XP)
I have 3 batch files
The first one does this:
Code:
SETLOCAL EnableDelayedExpansion
set count=1
md fix
copy *.corrupt fix
cd fix
FOR /F "tokens=1 delims=" %%A IN ('dir /b') DO (
SET infile=original!count!
echo !infile!
rename %%A !infile!
call log !infile!
SET /A COUNT=!COUNT!+1
)
Where log is the name of the 2nd batch file. which looks something like this:
Code:
set clp1=%1
IF NOT "%clp1%"== "" (set file1=%clp1%) else (set file1=original)
set file2=%file1%.one.txt
set file3=%file1%.two.txt
set file4=%file1%.three.txt
echo Original: %file1%
echo Log File: %file2%
echo Details: %file3%
echo One Line: %file4%
external1 %file1% 2>%file2% 1>>&2
echo. >>%file2%
external2 %file1% >>%file2%
external3 %file1% >>%file4%
call out %file1%
start %file1%
start %file2%
start %file3%
Out is the name of the 3rd of batch file, which does a whole load of stuff.
As you have probably worked out, the first batch file is just a tool to copy a whole load of corrupt files to a folder called fix, which it creates, then it calls the log batch file which runs 3 commands to generate some log files, this then calls the 3rd batch file which process one of the log files to create another file.
Now, the problem When these batch files finish running, I am left in the root folder, not the fix folder. I can see from the output window, when it runs the start lines, it is in the fix folder.
Why does it return to the root folder? I don't have a line that does cd.. or anything like that, and it never used to (I modified the first batch file to handle more than file (the whole For /F bit, before that it just had the
"call log original" line (with a line to rename *.corrupt to original)
Any one have any ideas?
Malc