for command issue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
glenm
Posts: 2
Joined: 15 Mar 2011 16:26

for command issue

#1 Post by glenm » 15 Mar 2011 16:32

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: for command issue

#2 Post by aGerman » 15 Mar 2011 17:35

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

Post Reply