Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Multiple commands in batch file loop

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 03-13-2008   #1 (permalink)
mrgou
Guest


 

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

My System SpecsSystem Spec
Old 03-13-2008   #2 (permalink)
Gordon Bell
Guest


 

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:
Quote:

> 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
My System SpecsSystem Spec
Old 03-13-2008   #3 (permalink)
Gordon Bell
Guest


 

Re: Multiple commands in batch file loop


Best to include the PowerShell equivalent: ;-)

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


Gordon Bell wrote:
Quote:

>
> 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:
Quote:

>> 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
My System SpecsSystem Spec
Old 03-13-2008   #4 (permalink)
Bob F.
Guest


 

Re: Multiple commands in batch file loop

Any relation to the DEC Gordon Bell?

--
BobF.
"Gordon Bell" <gsbell@xxxxxx> wrote in message
news:eAPN%23hUhIHA.5780@xxxxxx
Quote:

>
> Best to include the PowerShell equivalent: ;-)
>
> gci *.txt | % {Command1.exe $_.FullName; Command2.exe $_.FullName}
>
>
> Gordon Bell wrote:
Quote:

>>
>> 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:
Quote:

>>> 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
My System SpecsSystem Spec
Old 03-13-2008   #5 (permalink)
Gordon Bell
Guest


 

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:
Quote:

> Any relation to the DEC Gordon Bell?
My System SpecsSystem Spec
Old 03-13-2008   #6 (permalink)
Bob F.
Guest


 

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@xxxxxx> wrote in message
news:e5lCj0UhIHA.1204@xxxxxx
Quote:

>
> No, I get asked often though. He's at MS Research now.
>
> http://research.microsoft.com/users/gbell/
>
>
> Bob F. wrote:
Quote:

>> Any relation to the DEC Gordon Bell?
My System SpecsSystem Spec
Old 03-13-2008   #7 (permalink)
Zanten, Ben van
Guest


 

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@xxxxxx> wrote in message
news:eMTEYfUhIHA.5824@xxxxxx
Quote:

>
> 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:
Quote:

>> 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
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple commands in batch file loop mrgou Vista General 6 03-13-2008 04:55 PM
Batch file Bob Vista General 1 01-20-2008 07:39 AM
batch file calling exe file problem JPS Vista security 1 12-19-2007 07:18 PM
Bug spreading pipeline commands across multiple lines in a script Keith Hill [MVP] PowerShell 8 05-03-2007 10:17 PM
output format with multiple commands William Stacey [C# MVP] PowerShell 9 02-13-2007 11:34 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

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