MSFN Forum: [batch] FOR-command with spaces in arguments - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[batch] FOR-command with spaces in arguments Rate Topic: -----

#1 User is offline   my2001 

  • Member
  • PipPip
  • Group: Members
  • Posts: 260
  • Joined: 31-May 04

Posted 29 October 2004 - 04:15 AM

FOR %%d in (xxx yyy zzz) DO (
  echo %%d
)


That's my basic structure which, of course, works fine. But unfortunately one of my arguments (i.e. xxx, yyy and zzz) contains spaces, e.g. "x xx" and FOR-command recognizes this as two separate argruments then.

Isn't there a possibility except /F switch to tell FOR to that one argument contains spaces? I tried to use quotes like 'xxx' etc. but this didn't help.

I can't take the spaces out of the arguments b/c my arguments represent registry keys which woulnd't be valid any longer w/o the spaces.


#2 User is offline   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 30 October 2004 - 08:49 AM

Quote

FOR %%d in (xxx yyy zzz) DO (
echo %%d
)

Quote

FOR %%d in (

Quote

" I think these are needed
xxx yyy zzz (
" I think these are needed
) DO (
echo %%d
)

Quote

FOR %%d in ("xxx yyy zzz") DO (
echo %%d
   

I am not sure but this may work

#3 User is offline   jdoe 

  • Advanced Member
  • PipPipPip
  • Group: Banned
  • Posts: 314
  • Joined: 02-May 04

Posted 31 October 2004 - 05:18 AM

@my2001

I'm not sure to understand what you want but if I understand this code can solve the problem


FOR %%D IN ("XXX" "YYY" "ZZZ") DO ECHO %%~D




Hoping this help


:)

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy