Assigning multiple variables

ahoor used Ask the Experts™
If I look at this site:

If I do:
FOR /F %%G IN ("This is a long sentence") DO @echo %%G %%H %%J

I expect to get: This is long

I do get: This %H %J

What can be wrong?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
FOR /F does only take the first token found. You have to tell it which tokens you want to get.

A token is that part of the data which is enclosed in two delimiters. As you have not changed the default delimiters, they are whitespace (spaces and tabs) - this was as expected.

To get your example working, you have to use something like

for /F "tokens=1-5" %%G in ("This is a long sentence") do @echo %%G %%H %%J

It would have been sufficient to use "tokens=1-3".


Works perfect.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial