Multiple commands in batch file loop
I am running windows Vista enterprises. I have a small question hope you guys can help me out with this. I just wanted to know is it possible to execute more than one command in a batch file for each iteration of a FOR loop? I mean i want to run multiple commands for each file of the set. Is there anyway doing the same ?
Thanks for your helps.
Re: Multiple commands in batch file loop
Yes, it is possible. In order to do the same you can 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...
Let me know if you need anymore help with this.
Re: Multiple commands in batch file loop
That is correct to some extent Casher but better than that you should also include the PowerShell equivalent like this :
Quote:
gci *.txt | % {Command1.exe $_.FullName; Command2.exe $_.FullName}
Re: Multiple commands in batch file loop
I dont think you actually need to use a separate batchfile. Instead you can do that in the same batch by using ( and ) like this:
Quote:
For %%f in (*.txt) do (
Command1 %1
Command2 %1
)
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!
I hope this helps you guys too!
Re: Multiple commands in batch file loop
i need to test or avability of keyboard & mouse through batch file. Pl help
Re: Multiple commands in batch file loop
Why do you need to write a batch script to test your keyboard and mouse. It is really simple by interrogating the system you can esaily detect if your keyboard and mouse are enabled or disabled.
Alternative you can use the PassMark KeyboardTest -
It is a tool for advanced configuration for your keyboard. You may like to check that your keyboard keys and the LEDs (Num Lock, for example) work correctly. In addition, the application analyzes your typing and how you show your typing speed and sensitivity recommended depending on your habits.
Re: Multiple commands in batch file loop
hi guys i also have a problem. im trying to get my batch file to start over once it has finished.
my batch files looks like the following...
netsh wlan connect SKY03175 SKY03175
ping 127.0.0.1 -n10 -w 1000
ftp uploads.google.com
:top
GOTO top
now the batch file itself works fine. but the goto command only executes once i type in bye. and then all i get is a continouos list appearing like so
c:\GOTO top
c:\GOTO top
c:\GOTO top
c:\GOTO top
this doesnt stop until i manually stop it.
so basically the loop is failing to work in the way i want it to. help will be much appreciated :)
Re: Multiple commands in batch file loop
mkay i registered on the forum just to help you out, try something like this
:top
netsh wlan connect SKY03175 SKY03175
ping 127.0.0.1 -n10 -w 1000
ftp uploads.google.com
choice /c:yn /m "run again?"
if errorlevel 2 goto top
Re: Multiple commands in batch file loop
I prefer to go with a Batch File Maker. There are certain tools that can help you to generate a automated script for a process. You can edit that script and find the right command. Tool called as Batch File Maker is much easier to create batch files and modify them as per your need. The command line tool offer you to generate files with .bat exenstion and you can simply run them via cmd or run box. As the location for them is set to system32 folder inside Windows.
Re: Multiple commands in batch file loop
I remember a tool called as ZIP Batch File Maker. I had used this tool on Vista and it worked simply well. What I do not find is many customization option tha we need. There are certain sample script on the web that you can download and use. Somehow the most irritating stuff is when you get that error in a ongoing process. Still there is not proper application that can help to generate a good batch file.