Reputation: 23
Guys I have two challenges:
1- It is creating a script to count lines in a text file. With that I developed the script below that does the right count and is working perfectly
@echo off
cls
setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" myfile.txt | find /C ":""
for /f %%a in ('!cmd!') do set number=%%a
echo myfile.txt: %number%
pause
2- It is to create a new column that number the lines of the file.
Example: The file looks like this:
a
b
c
d
e
f
It should look like this:
a 1
b 2
c 3
d 4
e 5
f 6
does anyone know if it is possible to do this action in .bat?
Upvotes: 1
Views: 76
Reputation: 57252
@echo off
for /f "tokens=1* delims=:" %%a in ('findstr /n "^" "c:\myfile"') do (
(echo(%%b %%a)
)
?
Upvotes: 2