Help needed to write xcopy command

Hi everyone,
I'm in need of an xcopy command and would like to ask for your help.  I'm familiar with xcopy and I'm aware of the syntax but I'd like to hear from the experts about my particular scenario.

Source:
Z:\files

Destination:
J:\files


These directories have dozens of sub directories with contents.  

I need to transfer anything from the source that doesn't exist in the destination.  Basically, I need to perform a copy but don't overwrite existing contents in the destination.  It's a merge with no overwrite.

What's the best command to achieve this?

Thanks for your help!
AxISQSAsked:
Who is Participating?
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.

Steve KnightIT ConsultancyCommented:
xcopy /d /e Z:\files\*.* J:\files

or similar will copy from the source to destination only if the file in the source is newer or doesn't exist, does that work for you, or should it never overwrite even if it is older?

Robocopy might be better for you here:

robocopy /e /xc /xn /xo /xx /l Z:\files J:\files

taht should exclude any changed, newer, older files and just copy 'lonely' ones I think.

The /L will just SHOW you what it would copy, remove that to make it do it if happy.

Steve
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
Steve KnightIT ConsultancyCommented:
Here is a good explanation of the robocopy terms if it helps:

http://superuser.com/questions/314503/what-does-robocopy-mean-by-tweaked-lonely-and-extra
0
AxISQSAuthor Commented:
Hi Steve,
If the file is newer it should not be overwritten.

Sounds like the robocopy command is best.  Is there a need to specify contents of Z:\files, for example Z:\files\*.* ?
0
Steve KnightIT ConsultancyCommented:
no, robocopy uses directory names, not files for source.  try it with that /l option on and that you are happy with what it says it would copy.  as it stands it only copies new files NOT ones that are newer on the source server.

if updated files on source should make it overwriting dest. then xcopy /d or robocopy with ldss of the /x shortcuts is your anser.

steve
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
Microsoft DOS

From novice to tech pro — start learning today.