FOR Command in a batch file

  • Thread starter Thread starter pestrue
  • Start date Start date
P

pestrue

I have some old batch scripts I am trying to update to run on XP. My
problem is with the FOR Command where I had a line

for %%R in (*.doc) do set attachaas=!attachaas!,%%R

apparently the '!' doesn't do what it used to. I just need to get a
variable equal to

attachaas = '1.doc,2.doc,3.doc' etc.

Thanks

JP
 
I have some old batch scripts I am trying to update to run on XP. My
problem is with the FOR Command where I had a line

for %%R in (*.doc) do set attachaas=!attachaas!,%%R

apparently the '!' doesn't do what it used to. I just need to get a
variable equal to

attachaas = '1.doc,2.doc,3.doc' etc.

By default delayed variable expansion is off. You need to run cmd.exe with
the /V:ON switch to enable delayed variable expansion that will give the
behavior you want.
 
Back
Top