How would I be able to add line numbers to a text file from a batch file / command prompt?
e.g.
1 line1
2 line2
etc
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here you go:
This will probably only work in a batch file and not on the command line.
For more info, see this page.
If you want to loop over an existing file and add numbers to it, you’d have to process the file with a for /F loop instead, and within each loop iteration use a statement like
set /a counter+=1to increment your counter. Then spit out each line to a new file and finally replace the old file with the new one.