?
Solved

Run multiple Batch files

Posted on 2008-06-19
7
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

764 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