problem with space caracter and "for" interations

M

Matthieu

Hello,

I want to execute this script line : For /F %i in (list.txt) do net group
"%i" /domain > "%~ni"
the list.txt has lines like this :

"IM & Tech"
"Ina Fac"
"Industrial & Health"
"Industrial-Operation"
"IO-Bulk"
"IPG-P"
"ITM-TEST"

It works properly, but for lines with spaces between the words ( "Ina Fac"),
only the first word becomes %i (Ina) and the "net group %i /domain" comand
doesn't work.

What should I do ?

Thanks
Matthieu
 
W

William Allen

Hello,

I want to execute this script line : For /F %i in (list.txt) do net group
"%i" /domain > "%~ni"
the list.txt has lines like this :

"IM & Tech"
"Ina Fac"
"Industrial & Health"
"Industrial-Operation"
"IO-Bulk"
"IPG-P"
"ITM-TEST"

It works properly, but for lines with spaces between the words ( "Ina Fac"),
only the first word becomes %i (Ina) and the "net group %i /domain" comand
doesn't work.

What should I do ?

Try changing:
For /F %i in (list.txt) do (etc)
to:
For /F "tokens=*" %i in (list.txt) do (etc)

The syntax of FOR /F is explained in the /? help to FOR:
for /?

Note that you need to use %%i (with doubled %%) for the
metavariable syntax in a Batch file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top