Robocopy - Copy directory into another directory

84,470

Solution 1

If you want to create an exact duplicate, use the following version (which is equivalent to adding /E and /PURGE:

robocopy c:\source d:\destination /MIR

If all you want to do is copy the directories and subdirectories including empty ones, use

robocopy c:\source d:\destination /E

It is the backslash on the E option that was getting you.

To learn more about Robocopy here is a handy search:

http://www.google.com?q=robocopy+syntax

Solution 2

Although this answer doesn't use robocopy, I think it still does the purpose of copying directories.

You could try using: xcopy

Usage: xcopy source [destination] ...

You could check for more details by executing xcopy /?

Source: HOW TO: Copy a Folder to Another Folder and Retain its Permissions.

Share:
84,470

Related videos on Youtube

ng.newbie
Author by

ng.newbie

Updated on September 18, 2022

Comments

  • ng.newbie
    ng.newbie over 1 year

    I can't believe that I am having trouble in copying a directory into another directory via the windows command line.

    What I want to do is simple -:

    Lets say I have a directory -:

    C:\test
    

    and I want to copy test to D: So in D there should be a folder like the following-:

    D:\test
    

    when I use

    robocopy C:\test D:\test \E
    

    D drive ends up with the contents of C:\test in the root rather than being contained in a directory called test.

    How do you do this simple thing ?

  • Herb
    Herb almost 7 years
    You might want to fix the typo: in "robocopy d:\test d:\test /E" you need to address the source as C:, not D:.
  • SDsolar
    SDsolar almost 7 years
    by the way, here is something you might want to consider. If you do ROBOCOPY a lot, you probably have discovered that when the clocks don't agree it can end up recopying a lot of files because it thinks they are new. What you want to do is click on your clock(s) and find Internet Time and change the server to time.nist.gov on both then click on update. You can see the details in this Q&A I did on SE: raspberrypi.stackexchange.com/questions/68811/…?
  • Multinerd
    Multinerd over 5 years
    FYI: Robocopy replaces XCopy in later versions of windows