I need to copy folderA into folderB via the command line:


should become


That is, exactly the same as if you copied folderA using windows explorer and pasted it into folderB.

This does not work:

xcopy /e folder1 folder2\

as you end up with the contents of folderA in folderB and not folderA itself.

Funnily enough, move does exactly what I want except that it moves instead of copy :)

How do you copy a folder and include the folder itself as the base folder for the copy? I shouldn't have to use mkdir to create the target folder. (but that gets the job done nastily)

Please dont direct me to this as that does not do the above.


Thanks to the answers below using robocopy I found a solution using xcopy that doesnt prompt either:

xcopy /e /i folderA folderB\folderA

Use the /i option to avoid being asked whether the target is a directory or a file.

3 Answers 3



xcopy folder1 folder2\folder1 /e /i

robocopy \folderA \folderB\folderA /s will create folderA at the destination and perform a recursive copy. Check what other options you may want or require. e.g. /e if you want to include empty folders.



If I understand the parameters correctly, you'd want to do Robocopy C:\temp\folderA C:\temp\folderB /COPYALL /E /DCOPY:T

(Copy folder A into location B, preserve all attributes and ACLs, include all subfolders even empty ones, preserve directory timestamps.)

  • 1
    that doesnt work did you even try it? does exactly the same as xcopy command above, folderA is not copied.
    – wal
    Aug 6, 2012 at 3:55

Your Answer

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

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