Solved

Run multiple Batch files

Posted on 2008-06-19
7
371 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

16 Experts available now in Live!

Get 1:1 Help Now