Solved

Combine two batch files

Posted on 2015-02-03
6
294 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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 24

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

820 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