Solved

Combine two batch files

Posted on 2015-02-03
6
303 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
[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
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 96

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 96

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

628 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