Page 1 of 1

for command issue

Posted: 15 Mar 2011 16:32
by glenm
Hi,
I am a complete newbie on batch programming.
The following line is causing me a problem in my batch file

for /d %%X in ("%cd%\*") do echo %%X

When I run this within C:\Documents and Settings .i.e the %cd% value then it seems to have a problem with the spaces in "C:\Documents and Settings". I expected it to list all the directories in C:\Documents and Settings. It does on some windows boxes but not others.

I think its an issue with %'s but don't know the solution.
Can anyone help.
Thanks

Re: for command issue

Posted: 15 Mar 2011 17:35
by aGerman
I almost use the DIR command for those things

Code: Select all

for /f "tokens=* delims=" %%X in ('dir /ad /b') do echo %%X

BTW you don't need %cd%.

Regards
aGerman