Solved

Run multiple Batch files

Posted on 2008-06-19
7
372 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
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.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I delete 2 43
Using VB6 to write Excel Spreadsheets - 5 40
file size 9 41
File download script VBSCRIPT fail on download PPT files 2 37
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now