problem with space caracter and "for" interations

  • Thread starter Thread starter Matthieu
  • Start date Start date
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
 
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.
 
Back
Top