Discussion Locked

How to automate a cutting / moving / or

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Could someone please help me automate the process of copying files and directories to another server? I created a .bat file with the "xcopy" command with a /e switch. However, I would also like to automate the process of deleting them AFTER they have been copied.

Also, are there any things that I should be aware of? limitations? pitfalls?

Thanks!

7 replies

by joseph moore

Sure, it is easy. I am gonna assume a few things here: you have .JPG files in 3 sub-folders (ONE, TWO and THREE) in C:\FILES that you want to copy into F:\FILES. Write your BAT file like this:

@echo off
cd \
cd C:\FILES
XCOPY *.JPG F:\FILES /E /C /Q /H /R /K /Y
cd \
del C:\FILES /F /S /Q
EXIT

That is it. This will copy the files over to the specified location using a bunch of good switches for XCOPY, including the no screen display (to speed up the copy job), and the overwriting all option with no keyboard prompting. This will just fly!
Then, the delete line will delete all files in the C:\FILES directory and all sub directories without prompting for a yes/no deletion confirm.

Now, just set this file to run in Scheduled Jobs to run whenever you want it to run.

And the only caveat is to make sure you REALLY want to delete the files. Don't delete them if you really don't want to.

hope this helps

by curious_george

Use robocopy from the NT resource Kit it is like a superpowered xcopy use the /MIR switch.

Whammo !! All done!!

This discussion is closed to new replies.