Link to home
Start Free TrialLog in
Avatar of Jiggens
Jiggens

asked on

Run multiple Batch files

I have over 1000.Bat files that i have to run, What is the best way to do this, if anyone has a script or a link or can explain it to me , that would beg great.

thanks

exp.

run Bat1, bat2, bat3, bat4, out of folder /BatchFiles than delete batch files.
Avatar of Shift-3
Shift-3
Flag of United States of America image

Paste the script below into a text file with a .cmd extension.  Customize the value of the "folder" variable with the location of the BatchFiles folder.

Running the script will echo commands to run and delete every .bat file in that folder.  Once you have tested it successfully, remove the "echo" from lines 7 and 8.


@echo off
setlocal
 
set folder=C:\BatchFiles
 
for /F "tokens=*" %%G in ('dir "%folder%\*.bat" /B') do (
 echo call "%folder%\%%G"
 echo del "%folder%\%%G"
)
 
pause

Open in new window

Avatar of Jiggens
Jiggens

ASKER

i tested but they are not executing the echo call and echo del is showing for each file so its finding the folder and the file just not running?
Avatar of Jiggens

ASKER

The original batch files look like this


REM Activant
REM A fax failed to be sent out. This file has been created 
REM to resend the fax. Double click this file to resend the fax. 
REM 
vfx -H KMC.electricalsalesinc.local -B \\Sqlserver\jfsrvr\data\OR151704.rcp
REM Check to see if an error has occurred before continuing. 
pause 

Open in new window

Avatar of Jiggens

ASKER

I think i know why it wont run its because of the pause, its not going to execute in the existing batch file
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jiggens

ASKER

Yeah i am getting a message was unexpected at this time.

What does that mean?
I dunno.  You'll have to review the batch script that returned the error.

Personally I don't much fancy troubleshooting a thousand of the things.