More details... Use the "for" command to read from a text file and process info in it. The line
for /F %%i in (master.csv) do set MyFile=%%i
will read each line in the file master.csv, set %%i to the line, and run "set MyFile=%%i" for each line. At the end of this, MyFile will be equal to the last line.
Main Topics
Browse All Topics





by: Adam314Posted on 2005-09-30 at 12:31:01ID: 14995324
To set a variable in a script, use the set command. Here are some examples:
::Set MyFile to a constant filename
set MyFile=filename.txt
::set MyFile to the first parameter (eg: if your script was called test1.bat, and you typed "test1.bat filename.txt" on the command line)
set MyFile=%1
::set MyFile to the last line of filelist.txt
for /F %%i in (master.csv) do set MyFile=%%i
::Using any of the above statements will set MyFile. To "use" MyFile, surround it in percent signs %.
echo MyFile is now %MyFile%