Solved how to read and set variable from file.txt

May 25, 2012 at 14:19:15
Specs: Windows XP
I have file.txt which contains the name of file.txt as follows.
C:\BatchScript\test\bkk001.txt
C:\BatchScript\test\bkk002.txt
C:\BatchScript\test\ExampleFile.txt
C:\BatchScript\test\korat001.txt
C:\BatchScript\test\korat002.txt

And I need to set the name of file.txt in each line to variable in order to print out with nodepad.exe command.

NOTEPAD.EXE /PT "%filename%" "%printername%"


Could anyone kindly suggest me to solve this problem?


See More: how to read and set variable from file.txt

Report •


#1
June 8, 2012 at 12:22:28
✔ Best Answer
::untested
for /f "tokens=4 delims=\" %%G in (file.txt) DO NOTEPAD.EXE /PT "%%G" "%printername%"
::you will need to set the printername variable i assume

:: mike


Report •
Related Solutions


Ask Question