Un Known
Un Known

Reputation: 169

Can someone please explain this CMD batch file?

set SourceSCMPasswd=abc
set HATCONTESTING=yes 


for /f %%a in ('dir /AD /b')  do VssConverter.exe analyze %%a\settings.xml & move VSSAnalysisReport.xml %%a & move usermap.xml %%a

I know that it does the following commands: 1) Run VssConverter.exe analyze on %%a\settings.xml 2) Move VSSAnalysisReport.xml to %%a 3) Move usermap.xml to %%a

The problem is that when a folder in the directory has a space in its name, like AMEX Mailer for example, the variable %%a only contains AMEX but excludes the second part. How do I make it include the whole name?

Upvotes: 0

Views: 157

Answers (2)

dMb
dMb

Reputation: 9367

try this:

for /f "delims=" %%a in ...

Upvotes: 0

dbenham
dbenham

Reputation: 130919

The default token delimiter for FOR /F is <tab> and <space>. You want to preserve the entire string as a single token, so you want no delimiter ("DELIMS=") The default EOL option is ;. Any line that begins with ; will be ignored. Though unlikely, it is possible for a file name to begin with ;. You want to set EOL to some character that cannot appear in a name. Good candidates are :, *, and ?.

for /f "eol=: delims=" %%A in ...

Upvotes: 1

Related Questions