Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have these two directories

C:\dir1\
C:\dir2\

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
add comment

1 Answer

up vote 6 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.