Reputation: 933
Ok, so I'm creating a simple batch file that's meant to get lines from a text file, then pipe the output to wget and download them (Using the Windows port). The only issue I'm having is adding a number to a number within the for loop.
SETLOCAL ENABLEDELAYEDEXPANSION
set sum=0
%ECHO% "Reading %1... "
for /f "eol=# tokens=* delims= " %%a in (%1) do (
echo %%a | bin\wget -q %%a
SET /a sum=%sum%+1
echo Hit:%sum% %%a
)
%ECHO% "Done!"
ENDLOCAL
It's being called like 'call read_line.bat myfile.txt
Yes, I know I could just use wget -i myfile.txt, but I'd prefer to not use that and have control on other things (Output, and The obvious HIT: function)
Upvotes: 0
Views: 2321
Reputation: 56496
Try using !
instead of %
for sum
in order to really use delayed expansion:
for /f "eol=# tokens=* delims= " %%a in (%1) do (
echo %%a | bin\wget -q %%a
SET /a sum=!sum!+1
echo Hit:!sum! %%a
)
Upvotes: 2