This is what I want to do, a batch that reads a file (e.g. file.txt) and output line# + token.
This is what I tried to do (which obviously didn't work):
set count=0
set InputFile=file.txt
for /f "tokens=1-3 delims=," %%A IN (%InputFile%) DO (
set /a count+=1
echo %count%. %%A
)
file.txt contains:
something,else,
something1,else1,
something2,else2,
something3,else3,
etc.
What I would like to output, is:
1. something
2. something1
3. something2
etc.
What this code is actually throwing in the output:
0. someting
0. something1
0. something2
etc
Any ideas?
You need to add
SETLOCAL ENABLEDELAYEDEXPANSION
before youFOR
loop.Then change
echo %count%. %%A
toecho !count!. %%A
.