robocopy delete-before copy

is there a way to have robocopy delete changed destination files before it copies?

this is my script so far:
"C:\Program Files (x86)\Windows Resource Kits\Tools\robocopy.exe" E:\shares F:\shares-backup /PURGE /E /SEC /R:5 /W:60 /NP > "C:\scripts\logs\shares_backup.txt"

thanks
Andrea_JennisonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
What exactly is it you're trying to do? robocopy will overwrite changed files, which is as good as deleting them.
0
Andrea_JennisonAuthor Commented:
The problem I am having is when robocopy(ing) one disk to another. For example, I have two disks of equal 100GB size, disk0 and disk1: disk0 is my source and disk1 is my destination. The contents of disk0 are folderA and folderB. The contents of disk0\folderA is 75GB in size, disk0\folderB is 0GB.

I run the following line: (all works ok)
C:\Program Files (x86)\Windows Resource Kits\Tools\robocopy.exe" E:\shares F:\shares-backup /PURGE /E /SEC /R:5 /W:60 /NP

After running the above line, disk0 and disk1 are effectively sync. All is good!

The problem occurs when I move the 75GB contents of disk0\folderA to disk0\folderB and run (again):
C:\Program Files (x86)\Windows Resource Kits\Tools\robocopy.exe" E:\shares F:\shares-backup /PURGE /E /SEC /R:5 /W:60 /NP

Robocopy first tries to copy the contents of disk0\folderB to disk1\folderB before deleting the contents of disk0\folderA. If I have explained this correctly, you will see that robocopy by first copying exceeds the total capacity of disk1.

Thoughts?
0
oBdACommented:
Then you need to make two runs; in the first, you just purge, in the second, you copy:
C:\Program Files (x86)\Windows Resource Kits\Tools\robocopy.exe" E:\shares F:\shares-backup /nocopy /PURGE /E /R:5 /W:60 /NP
C:\Program Files (x86)\Windows Resource Kits\Tools\robocopy.exe" E:\shares F:\shares-backup /E /SEC /R:5 /W:60 /NP

Which, of course, means that if the copy fails after the purge, your backup is gone ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrea_JennisonAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.