Solved .bat file FOR /F problem

May 10, 2012 at 06:30:02
Specs: Windows XP
The problem is that the SET commands are not setting the variables.

here is the script:

FOR /F %%b IN (%WORKING_LOCATION%\dgnFIX.txt) DO (
FOR /F %%z IN (%WORKING_LOCATION%\temp\DGN%%b.txt) DO (set _DGNinfo=%%z)
echo %_DGNinfo%

FOR /F %%y IN (%WORKING_LOCATION%\temp\DRV%%b.txt) DO (set _DRVinfo=%%y)
echo %_DRVinfo%
)


This is what happens when it runs:

C:\bat_test>(
FOR /F %z IN (C:\bat_test\temp\DGNsh60sh057.txt) DO (set _DGNinfo=%z )
echo
FOR /F %y IN (C:\bat_test\temp\DRVsh60sh057.txt) DO (set _DRVinfo=%y )
echo
)

C:\bat_test>(set _DGNinfo=05092012 )
ECHO is on.

C:\bat_test>(set _DRVinfo=04162012 )
ECHO is on.


See More: .bat file FOR /F problem

Report •


#1
May 10, 2012 at 10:00:23
✔ Best Answer
figured it out....

FOR /F %%b IN (%WORKING_LOCATION%\dgnFIX.txt) DO (
FOR /F %%g IN ('type %WORKING_LOCATION%\temp\DGN%%b.txt') DO (
FOR /F %%h IN ('type %WORKING_LOCATION%\temp\DRV%%b.txt') DO (
IF %%g GTR %%h echo %%b >>%WORKING_LOCATION%\test.txt
)
)
)


Report •
Related Solutions


Ask Question