Page 1 of 1

For /F to process multiple lines

Posted: 27 May 2021 08:52
by AR Coding
Hi, im pretty new to batch , and im not sure if this topic was spoken about Already on this forum. Im not very good at searching. So hear is my question:

is it possible for, for /f to process a command that outputs more then one line?
Here is my example:
For /F "delims=:" %%G in ('systeminfo') do (
set "%%G=%%H"
rem HERE IS WHERE I GET STUCK
)

%%G is going to equal OS NAME and %%H is going to equal AR Coding.
I want for to process all the lines. I want to be able to set all the lines after that also as variables. Is that possible?

Re: For /F to process multiple lines

Posted: 27 May 2021 14:18
by npocmaka_
you havent defined the tokens you want to get.

try with

Code: Select all

For /F "tokens=1* delims=:" %%G in (
  'systeminfo'
) do (
  set "%%G=%%H"
)

tokens option will assign the string before the first `:` to the %%G and everything else to the %%H

Re: For /F to process multiple lines

Posted: 27 May 2021 16:46
by AR Coding
Thank you so much for the fast reply! I didnt think it was necessary to specify which tokens i want.