2770Views2Replies

Author Options:

Batch. Reading multiple lines from a text file? Answered

I created a batch file, everytime it runs it saves a name and date to a log (log.txt). So everytime it gets more and more lines. I want to know how to read all the lines from File.txt (in another Batch file). my current script is:
@echo off
set /p txt= > File.txt
set /p txt2= >> File.txt
set /p txt3= >> File.txt
set /p txt4= >> File.txt
set /p txt5= >> File.txt
'and so on
echo %txt%
echo %txt1%
echo %txt2%
echo %txt3%
echo %txt4%
echo %txt5%


Every time i run it, it says "did not expect >>"
Please help

2 Replies

user
wkterBest Answer (author)2010-11-05

If you want to echo an entire txt file in a batch, simply type this: "type File.txt". That will output an entire txt file with no questions asked. If you want to loop through an entire txt file and actually do something else with the text (Like placing them in variables), have a look at the /f loop command here: http://ss64.com/nt/for_f.html .

Select as Best AnswerUndo Best Answer

user
animan1 (author)wkter2010-11-07