Solved

Run multiple Batch files

Posted on 2008-06-19
7
373 Views
Last Modified: 2010-04-16
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.
0
Comment
Question by:Jiggens
  • 4
  • 3
7 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 21824789
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

0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825321
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?
0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825362
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

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:Jiggens
ID: 21825400
I think i know why it wont run its because of the pause, its not going to execute in the existing batch file
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 21825843
Try this to bypass the pauses.


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

Open in new window

0
 
LVL 1

Author Comment

by:Jiggens
ID: 21825960
Yeah i am getting a message was unexpected at this time.

What does that mean?
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 21827675
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.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
batch script 3 37
Batch File won't run on Windows Server 2012 R2 Task Scheduler 8 35
How to remove unwanted words? 34 38
VBA taking too long 5 18
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question