Robocopy - Copy directory into another directory

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 ?

3 Answers

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:

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.

1

Use Robocopy (Robust File Copy)

robocopy c:\test d:\test /s /e *.*

/s switch is for copying all sub directories and /e switch is for copying all the empty sub directories & *.* means (all files).(any extensions)

syntax:

robocopy source-folder destination-folder files switches

Please visit this link for more information about robocopy.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like