0

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.???

1
  • 4
    Give us an example. Show us the input you need your batch file to read. Is the input a text file or output from another command? Commented Aug 30, 2011 at 3:13

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.