Solved

Combine two batch files

Posted on 2015-02-03
6
285 Views
Last Modified: 2015-02-03
How can I combine the following two batch files

"C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off

Open in new window

and
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

0
Comment
Question by:Gerhardpet
6 Comments
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 40587592
Can you not just merge them into a single file?  The call to the PSQL Backup Agent should fire, and when it comes back, the other two commands should run.  Remember to always give the Backup Agent some time to complete its task -- pulling a large file set out of Continuous Operations mode may take a while, especially if the disk is busy.

If you really want to leave them separate, then you can create a THIRD batch file like this:
    CALL BatchA
    CALL BatchB
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40587600
Agreed, just put the three commands together one after another, unless the first command when it runs returns straight away to the batch file and completes it's work in the background?

Presumably you want to remove the older files using forfiles then run the backup process?

Steve
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 40587607
Batch files execute in sequence and wait for the command run to complete.  If you don't want the batch file to wait, then you use "start"

For example:
"C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

will execute PVBackup.exe and wait for it to complete.  Once completed it will run the first ForFiles command.

If you want pvbackup.exe to run start and then have for files execute nearly instantly after pvbackup starts, you use start, like this:
Start "" "C:\Program Files (x86)\Pervasive Software\PSQL\PBA\bin\pvbackup.exe" -off
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.backup /c "cmd /c del @file"
forfiles /p "D:\Google Drive\xTuple Backups" /s /d -5 /m *.sql /c "cmd /c del @file"

Open in new window

0
Make managing Office 365 email signatures a breeze

Are you using Office 365? Having trouble trying to set up email signatures for your users? Getting stressed out managing multiple signatures? Need an easier way to manage? We have a solution for you, try the most-user friendly and powerful signature management tool on the market.

 
LVL 1

Author Comment

by:Gerhardpet
ID: 40587729
So if I combine all of them into one file will each line finish first before the next one starts?
0
 
LVL 23

Expert Comment

by:NVIT
ID: 40587731
The first example will.
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 40587733
Yes, that's what I said - Batch files execute in sequence and wait for the command run to complete.

That said, there is a CHANCE it won't if the pvbackup.exe actually starts another program and exits.  Only way to know for sure is to test.
0

Featured Post

Are your end users making ugly email signatures?

Have you left it up to your end users to create their own email signatures? Are they forgetting to add the company logo or using garish font colors? Take control and ensure all users have the same email signature.

Question has a verified solution.

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

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

943 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

10 Experts available now in Live!

Get 1:1 Help Now