• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 547
  • Last Modified:

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.



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!
  • 3
1 Solution
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 KnightIT ConsultancyCommented:
Here is a good explanation of the robocopy terms if it helps:

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\*.* ?
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now