Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I usually love Vista but I've found its file moving facilities are just bad.

I have these two directories


They both contain a number of subdirectories, which themselves contain files and subdirectories and so forth. And they're basically both the same structure, but the contents of the files is different.

What I want to do is take all the subdirectories of C:\dir1\ and move them to C:\dir2\, overwriting what is in C:\dir1\.

If I do this by dragging in Windows Explorer - it just doesn't work. It asks if I'm sure I want to merge but after that it does nothing.

If I do this one directory at a time, sometimes it works and sometimes it doesn't. And when it does work, it leaves the original directory in place, empty, which is harmless but weird.

What's a good, automatic and preferrably command-line way to say "move the contents of this directory over the contents of this directory, yes I'm serious, yes overwrite everything, no don't ask me any more questions, period"?

Also please tell me if Windows 7 fixes this crap.

share|improve this question
up vote 7 down vote accepted

xcopy c:\dir1 c:\dir2 /E /H /R /X /Y /I /K

does the trick.

Works from Vista and 7 from the command line.

For info, this is what the switches do in this command:

  • /E Copies directories and subdirectories, including empty ones.
  • /H Copies hidden and system files also.
  • /R Overwrites read-only files.
  • /X Copies file audit settings (implies /O).
  • /Y Suppresses prompting to confirm you want to overwrite an existing destination file.
  • /I If destination does not exist and copying more than one file, assumes that destination must be a directory.
  • /K Copies attributes. Normal Xcopy will reset read-only attributes.

You can find out more info by typing xcopy /? at the command line.

If you then want to complete the "move", you simply delete c:\dir1 with rd c:\dir1 /S /Q

Might be worth sticking these two commands in a batch file (a text file with either .cmd or .bat on the end) using Notepad. Then you simply have to double-click the shortcut.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .