Reputation: 1
can you please tell me how to get input from another file. Also when we got the outputs from that file..tel me how to use that as an input to batch script if it has multiple outputs from the other file.???
Upvotes: 0
Views: 593
Reputation: 15919
To get input from a text file to a variable:
set /p var=<file.txt
A nifty way to set multiple variables if your text file has multiple lines, you may do this (use %%A for batch files and %A for CLI commands):
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "USEBACKQ tokens=*" %%A IN (`type "file.txt"`) DO (
SET var!count!=%%A
SET /a count=!count!+1
)
So then the first line will be var1, the second line will be var2, so on and so forth. Then when you wish to reuse the variables, just call them using %var1%, %var2% etc.
Upvotes: 1