Saturday, July 6, 2013

CMD DOS Read file in for loop example

CMD DOS Read file in for loop example





C:\testscripts>type newFile.txt
My File Line 1
My File Line 2
My File Line 3

C:\testscripts>test.cmd
This is to show how DOS can read a file

line = My File Line 1
line = My File Line 2
line = My File Line 3

done

C:\testscripts> type test.cmd
@echo off
echo This is to show how DOS can read a file
echo.
for /f  "tokens=*" %%i in (newFile.txt) DO echo line = %%i
echo.
echo done
exit /b 1
goto :eof
C:\testscripts>

No comments:

Post a Comment