Is it possible to pipe in a .txt file as a command line argument to a batch file?
For example, I am looking to call
./program components.txt
Then use every line of components.txt as arguments to a function I call inside my batch file.
If args.txt contains a list of command-line arguments to your executable (one per line), you could use something like this:
@echo off
setlocal enableextensions enabledelayedexpansion
set ARGS=
for /f "delims=" %%a in ('type args.txt') do (
set ARGS=!ARGS! %%a
)
.\program %ARGS%
endlocal
call to run it (e.g., call .\scriptname %ARGS%).for command reads the file args.txt and constructs the ARGS environment variable as a single space-delimited string containing the lines from the file (i.e., spaces between instead of newlines). What you do with that string is up to you.