Multiple commands in batch file loop

M

mrgou

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 Computer

G

Gordon Bell

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
 

My Computer

G

Gordon Bell

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
 

My Computer

B

Bob F.

Any relation to the DEC Gordon Bell?

--
BobF.
"Gordon Bell" <[email protected]> wrote in message
news:eAPN%[email protected]

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

My Computer

Z

Zanten, Ben van

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" <[email protected]> wrote in message
news:[email protected]

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

My Computer

Top