Jump to content

Recommended Posts

Posted

I have a batch file that is set to copy a large quantity of files from a network share, but I want to run another batch file immediately after the first one finishes but with files from another network location.

 

At present I have...

 

xcopy \\EARTH\usbdisk2\Movies S:\Movies\ /E /F /K /J

 

....in one batch file, and an identical command in another batch file (just a different source location)

 

How can I achieve what I need to do please? I intend to run these as scheduled tasks when a user logs off from a workstation. i.e overnight.

Posted

Having found out how long the first one takes, can you not just schedule them both so that the second one starts as near to the completion of the first one as you can?

Or is that not do-able?

Posted
Having found out how long the first one takes, can you not just schedule them both so that the second one starts as near to the completion of the first one as you can?

Or is that not do-able?

 

I am going to be copying almost 90GB of data over the network in the first batch, slightly less in the second round, so guesswork isn't really an option at this stage.

Posted
CALL file2.bat

 

I place that at the end of the 1st batch I presume, which will then run the 2nd?

Or as you mention further down, put them in the same file - I wasn't sure about this when I though of that; I definitely don't want them running together, so I didn't try it. They would definitely run one after the other if they were in the same file? Any sort of 'separator' needed?

Posted
I place that at the end of the 1st batch I presume, which will then run the 2nd?

Or as you mention further down, put them in the same file - I wasn't sure about this when I though of that; I definitely don't want them running together, so I didn't try it. They would definitely run one after the other if they were in the same file? Any sort of 'separator' needed?

 

I would put them one after the other in the same file. No seperator needed, CMD will run the first line then the second line - one after the other.

You could always just add a "pause" at the end to check that the commands have run correctly without any errors before the batch file exits.

  • Thanks 1
Posted (edited)

You can even do the following where the second command will only run if the first was successful.

 

xcopy \\EARTH\usbdisk2\Movies S:\Movies\ /E /F /K /J [b]&&[/b] xcopy \\SUN\usbdisk2\Movies S:\Movies\ /E /F /K /J

 

 

Personally, whenever I have to copy a huge amounts of data I use RoboCopy. It has more options than XCopy e.g. it can log everything to a text file so you can make sure nothing was missed, and the latest version can use more than one thread which will make the file transfer take a lot less time.

Edited by Arthur
  • Thanks 1
Posted (edited)

SS64 is a good resource for useful command line tools

 

Call

 

 

Call one batch program from another.

 

Syntax

CALL [drive:][path]filename [parameters]

 

CALL :label [parameters]

 

CALL internal_cmd

 

Key:

pathname The batch program to run

 

parameters Any command-line arguments

 

:label Jump to a label in the current batch script.

 

internal_cmd Any internal command, first expanding any variables in the argument

 

You could also use start /wait to start other files such as cmd etc.

 

Start - Start a program

 

Start a specified program or command in a separate window.

 

Syntax

START "title" [/Dpath] [options] "command" [parameters]

 

Key:

title : Text for the CMD window title bar (required)

path : Starting directory

command : The command, batch file or executable program to run

parameters : The parameters passed to the command

 

Options:

/MIN : Minimized

/MAX : Maximized

/WAIT : Start application and wait for it to terminate

/LOW : Use IDLE priority class

/NORMAL : Use NORMAL priority class

/HIGH : Use HIGH priority class

/REALTIME : Use REALTIME priority class

 

/B : Start application without creating a new window. In this case

^C will be ignored - leaving ^Break as the only way to

interrupt the application

/I : Ignore any changes to the current environment.

 

Forcing a Sequence of Programs

If you require your users to run a sequence of 32 bit GUI programs to complete a task, create a batch file that uses the start command:

 

@echo off

start /wait /b First.exe

start /wait /b Second.exe

start /wait /b Third.exe

 

Create a shortcut to this batch file and place it on the Start menu or desktop. Set it to run minimized.

When the user double-clicks the shortcut, runs.

When terminates, runs

When terminates, runs

 

Robocopy

 

Syntax

ROBOCOPY source_folder destination_folder [file(s)_to_copy] [options]

Edited by somabc
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...