Welcome to WinForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

FOR Command in a batch file

 
   Windows XP (Home) -> XP General Discussion RSS
Next:  XP Disk Defragmenter Woes  
Author Message
pestrue

External


Since: Feb 16, 2007
Posts: 2



(Msg. 1) Posted: Fri Feb 16, 2007 9:47 am
Post subject: FOR Command in a batch file
Archived from groups: microsoft>public>windowsxp>general (more info?)

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

 >> Stay informed about: FOR Command in a batch file 
Back to top
Login to vote
pestrue

External


Since: Feb 16, 2007
Posts: 2



(Msg. 2) Posted: Fri Feb 16, 2007 9:47 am
Post subject: FOR Command in a batch file
Archived from groups: per prev. post (more info?)

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

 >> Stay informed about: FOR Command in a batch file 
Back to top
Login to vote
Tom Porterfield

External


Since: Feb 20, 2004
Posts: 168



(Msg. 3) Posted: Fri Feb 16, 2007 1:13 pm
Post subject: Re: FOR Command in a batch file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

pestrue.TakeThisOut@gmail.com wrote:
> 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.
--
Tom Porterfield
 >> Stay informed about: FOR Command in a batch file 
Back to top
Login to vote
Tom Porterfield

External


Since: Feb 20, 2004
Posts: 168



(Msg. 4) Posted: Fri Feb 16, 2007 1:13 pm
Post subject: Re: FOR Command in a batch file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

pestrue RemoveThis @gmail.com wrote:
> 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.
--
Tom Porterfield
 >> Stay informed about: FOR Command in a batch file 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Batch File - I have created a batch file to run Azureus with a fixed amount of memory: Azureus.exe -J-Xmx64m It works just fine, but after Azureus loads, the batch file window is still open. How can I configure the batch file so that the window closes after it i...

Can I do this with a script or batch file? - Supposing I have a number of identical laptops running XP SP2 and I want to disable the CD ROM or some other device in Device Manager. Is there a way I can create and run a script which I can run from each machine to do this for me to same a great deal o...

Rename in a batch file - This is a batch programming issue, so I'm not sure if this is the right newsgroup. If not, maybe someone could suggest a better one. In a batch file which runs a backup I want the last line to rename the log file name_of_backup_job.txt to ..

Digitally signing a batch file? - Do you know if you can digitally sign a batch file (.bat)? If so, what tool do you use to apply the digital certificate to the batch file? Thanks.

MSDOS Batch File Question! - Hi, I am trying to write a batch file to delete all files older than one hour within a folder. Because of some restriction, I cannot use any 3rd party tool to do that. What would be the most efficient MSDOS batch file to that? Any help would...
   Windows XP (Home) -> XP General Discussion All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
  Windows XP
 Windows Vista!
 Win 2000/NT/98/ME


[ Contact us | Terms of Service/Privacy Policy ]