Microsoft Windows Vista Community Forums - Vistaheads
Recommended Download



Welcome to the Microsoft Windows Vista Community Forums - Vistaheads, YOUR Largest Resource for Windows Vista related information.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so , join our community today!

If you have any problems with the registration process or your account login, please contact us.

Driver Scanner

Multiple commands in batch file loop

microsoft.public.windows.vista.general






Speedup My PC
Reply
  #1 (permalink)  
Old 03-13-2008
mrgou
 

Posts: n/a
Multiple commands in batch file loop
Hi,

In a batch file, is it possible to execute more than one command for
each iteration of a FOR loop (i.e. more than one command for each file
of the set)?

Thanks!

mrgou
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-13-2008
Gordon Bell
 

Posts: n/a
Re: Multiple commands in batch file loop

Create a secondary batch file that processes each file and call it like
this:

for %f in (*.txt) do call process.bat %f


=process.bat=
@Echo Off
Command1.exe %1
Command2.exe %1
etc...


HTH


mrgou wrote:
> Hi,
>
> In a batch file, is it possible to execute more than one command for
> each iteration of a FOR loop (i.e. more than one command for each file
> of the set)?
>
> Thanks!
>
> mrgou

Reply With Quote
  #3 (permalink)  
Old 03-13-2008
Gordon Bell
 

Posts: n/a
Re: Multiple commands in batch file loop

Best to include the PowerShell equivalent: ;-)

gci *.txt | % {Command1.exe $_.FullName; Command2.exe $_.FullName}


Gordon Bell wrote:
>
> Create a secondary batch file that processes each file and call it like
> this:
>
> for %f in (*.txt) do call process.bat %f
>
>
> =process.bat=
> @Echo Off
> Command1.exe %1
> Command2.exe %1
> etc...
>
>
> HTH
>
>
> mrgou wrote:
>> Hi,
>>
>> In a batch file, is it possible to execute more than one command for
>> each iteration of a FOR loop (i.e. more than one command for each file
>> of the set)?
>>
>> Thanks!
>>
>> mrgou

Reply With Quote
  #4 (permalink)  
Old 03-13-2008
Bob F.
 

Posts: n/a
Re: Multiple commands in batch file loop
Any relation to the DEC Gordon Bell?

--
BobF.
"Gordon Bell" <gsbell@hotmail.com> wrote in message
news:eAPN%23hUhIHA.5780@TK2MSFTNGP06.phx.gbl...
>
> Best to include the PowerShell equivalent: ;-)
>
> gci *.txt | % {Command1.exe $_.FullName; Command2.exe $_.FullName}
>
>
> Gordon Bell wrote:
>>
>> Create a secondary batch file that processes each file and call it like
>> this:
>>
>> for %f in (*.txt) do call process.bat %f
>>
>>
>> =process.bat=
>> @Echo Off
>> Command1.exe %1
>> Command2.exe %1
>> etc...
>>
>>
>> HTH
>>
>>
>> mrgou wrote:
>>> Hi,
>>>
>>> In a batch file, is it possible to execute more than one command for
>>> each iteration of a FOR loop (i.e. more than one command for each file
>>> of the set)?
>>>
>>> Thanks!
>>>
>>> mrgou


Reply With Quote
  #5 (permalink)  
Old 03-13-2008
Gordon Bell
 

Posts: n/a
Re: Multiple commands in batch file loop

No, I get asked often though. He's at MS Research now.

http://research.microsoft.com/users/gbell/


Bob F. wrote:
> Any relation to the DEC Gordon Bell?

Reply With Quote
  #6 (permalink)  
Old 03-13-2008
Bob F.
 

Posts: n/a
Re: Multiple commands in batch file loop
yup...we were business acquaint nesses during his DEC and my Heath Co. days.

--
BobF.
"Gordon Bell" <gsbell@hotmail.com> wrote in message
news:e5lCj0UhIHA.1204@TK2MSFTNGP03.phx.gbl...
>
> No, I get asked often though. He's at MS Research now.
>
> http://research.microsoft.com/users/gbell/
>
>
> Bob F. wrote:
>> Any relation to the DEC Gordon Bell?


Reply With Quote
  #7 (permalink)  
Old 03-13-2008
Zanten, Ben van
 

Posts: n/a
Re: Multiple commands in batch file loop
Hi,
this newsgroup is about powershell, not batch, but I'll answer anyway.
You don't need to use a separate batchfile, you can do that in the same
batch by using ( and ) like this:

For %%f in (*.txt) do (
Command1 %1
Command2 %1
)

Greetz,
Ben

"Gordon Bell" <gsbell@hotmail.com> wrote in message
news:eMTEYfUhIHA.5824@TK2MSFTNGP03.phx.gbl...
>
> Create a secondary batch file that processes each file and call it like
> this:
>
> for %f in (*.txt) do call process.bat %f
>
>
> =process.bat=
> @Echo Off
> Command1.exe %1
> Command2.exe %1
> etc...
>
>
> HTH
>
>
> mrgou wrote:
>> Hi,
>>
>> In a batch file, is it possible to execute more than one command for
>> each iteration of a FOR loop (i.e. more than one command for each file
>> of the set)?
>>
>> Thanks!
>>
>> mrgou


Reply With Quote
  #8 (permalink)  
Old 02-18-2009
Stroud
 

Posts: n/a
Re: Multiple commands in batch file loop

Hey even I was trying to find an answer for the same problem with
commands in loop! Here i found some help with the 'batch files for loop'
(http://forums.techarena.in/software-...tm#post4249235)!
I hope this helps you guys too!


--
Stroud
------------------------------------------------------------------------
Stroud's Profile: http://forums.techarena.in/members/stroud.htm
View this thread: http://forums.techarena.in/vista-help/931481.htm

http://forums.techarena.in

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch file Bob microsoft.public.windows.vista.general 1 01-20-2008 14:39
Batch file Bob microsoft.public.windows.vista.file management 0 01-06-2008 21:39
batch file calling exe file problem JPS microsoft.public.windows.vista.security 1 12-20-2007 02:18
Need help with batch file n o s p a m p l e a s e microsoft.public.windows.vista.general 11 10-14-2007 07:35
Set file associations, commands and icons. Cat microsoft.public.windows.vista.general 3 03-01-2007 12:00




All times are GMT +1. The time now is 02:02.




Driver Scanner - Free Scan Now

Vistaheads.com is part of the Heads Network. See also XPHeads.com , Win7Heads.com and Win8Heads.com.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.0 RC 2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120