Solved Bat file that reads each line in a file and writes on other

September 4, 2012 at 10:15:15
Specs: Windows 7
Let's say I have a text file, PASS.txt with three lines of text :

vb235mn
452klm
332ght

I need a bat file that reads each line, creates consecutive text files (PASS1.txt, PASS2.txt, PASS3.txt and so on) and places each text line in each of these files. So, if I have a PASS.txt file with 100 lines, 100 text files (PASS1.txt...PASS100.txt) would be created, each with its corresponding text.


See More: Bat file that reads each line in a file and writes on other

Report •


#1
September 4, 2012 at 12:22:36
@for /f "tokens=1-2 delims=[]" %%a in ('find /v /n "" ^<pass.txt') do >pass%%a echo %%b
:end
might work, as long as none of the passes contain [ or ]

Report •

#2
September 4, 2012 at 12:53:39
It works as far as collating the lines, but the files created do not carry the file suffix, so I get "pass1" instead of "pass1.txt"...how can we correct that ?

Report •

#3
September 4, 2012 at 13:33:49
✔ Best Answer
@for /f "tokens=1-2 delims=[]" %%a in ('find /v /n "" ^<pass.txt') do >pass%%a.txt echo %%b


sorry, my bad! forgot to tag that onto the filename. this will fix it.


Report •

Related Solutions


Ask Question