This line will do what you want:
for /F "tokens=3" %v in ('BAT1.bat') do call BAT2.bat %v
What this line does is call BAT1.bat
, then parses its output using the options specified after the /F
. Specifically, "tokens=3"
tells the shell to take the third token and put it in the variable. Then, BAT2.bat
is called with the variable as its parameter.
Assuming you are going to use this in a batch file, you're going to want to double the percent signs:
for /F "tokens=3" %%v in ('BAT1.bat') do call BAT2.bat %%v
For more details, type
for /?
from the command line