.BAT to output different line every time

August 25, 2011 at 09:19:03
Specs: Windows XP
Hello forum peeps :]

I've seen plenty of batch file posts here but they don't quite do what i need (although still very helpful).

I would like a batch file to display a single word (or the whole line, doesn't matter which) from the first line of a .txt file, then if run again, display the second line of that file and so on until the last line of that file, then starting again from the first line.

I found this code that reads the first word in the file and displays it:

for /F "tokens=1 delims=," %%i in (myfile.txt) do @echo %%i

and then this code to display any line of the .txt file:

setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myfile.txt) do (
set /a N+=1
set v!N!=%%a
set line1=!v1!
set line2=!v2!
set line3=!v3!

echo %v1%
echo %v2%
echo %v3%

which is great, but i don't know how to add the bit about displaying the next line (or word) in the file if it's run again. Or maybe a different line of text depending on what day it is.

Maybe somebody can help me out. Thanks.

Ash :]

See More: .BAT to output different line every time

Report •

September 6, 2011 at 09:15:25
bump :]

Report •
Related Solutions

Ask Question