I have a build.bat file which uses %1 internally… so you might call:
build 1.23
I wanted it to read the parameter from a separate file, so I tried putting “1.23” in version.txt and doing:
build < version.txt
But it doesn’t work. Isn’t this how piping works? Is what I want possible and if so how?
The
FORcommand in DOS has a form which parses files and assigns the tokens it finds to variables, which can then be used as arguments to other batch files. Assumingversion.txtcontains the single line “1.23”, this batch file will open it, assign 1.23 to the variable, then call your original batch file, passing the variable’s value as a command-line argument.If
version.txtcontains more than one line,build.batis called once for each line. Typehelp forat a DOS prompt to see what other features you might be able to use.