The following is an example of the Windows batch file to read a text file line by line.
Windows Batch File Example: Read Text File
The below batch program will read the text file (dummy.txt) from the current directory and will put the line into a variable, then will echo (print) the line on the screen.
Contents of the dummy.txt file.
This is the first line. This is the second line. This is the third line. This is the forth line. This is the fifth line.
readfile.bat
@echo off for /f "tokens=*" %%s in (dummy.txt) do ( echo %%s ) pause
Test
To test create and put both the files into the same directory. Then run the file by typing its name at the Windows command prompt.
readfile.bat
Output
This is the first line. This is the second line. This is the third line. This is the forth line. This is the fifth line. Press any key to continue . . .
I have several folders listing show name and episode numbers. The show names are different lengths so I can not use TOKENS as a locator. The episode description is always 6 characters ie S01E01. I would like to run a batch which would check each folder for the sequence of episodes to see if any were missed or double entry of episode