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 want to copy the directory itself, not only the contents.

For example I have

C:\DirA\SubDirA\FileA

I want to copy DirA into DirB so that I have

C:\DirB\DirA\SubDirA\FileA

Here's what I've tried

copy C:\DirA C:\DirB
xcopy C:\DirA C:\DirB /e /s

But whatever I try to do, DirA gets left out

C:\DirB\SubDirA\FileA

Note: I have a list of directories I want to copy, so I don't know the directory name beforehand and I can't afford to run a heavyweight program like robocopy 1,000 times.

share|improve this question
add comment

2 Answers

Try Powershell's Copy-item:

copy-item C:\DirA -Destination C:\DirB -Recurse

OR

cp C:\DirA -Destination C:\DirB -Recurse

share|improve this answer
    
The Linux cp command also functions as an alias for copy-item. –  Davidw Aug 13 '13 at 4:41
add comment

Easiest way would be:

xcopy C:\DirA\* C:\DirB\DirA /e /s

Or say your had the folder set as var %foo% in a batch for script

xcopy C:\%foo%\* C:\DirB\%foo%\ /e /s

EDIT:

Also if you are happy to use powershell over Command Prompt

Copy-Item c:\DirA c:\DirB -recurse

share|improve this answer
    
So I have to explicitly specify the source root folder name in the target path as well? Does Windows not have an equivalent to linux's copy -R /mypath /another_existing_path ? –  David Aug 13 '13 at 4:21
    
Not that I know of from cmd - for reference copy xcopy robocopy –  50-3 Aug 13 '13 at 4:31
    
Powershell does. –  Davidw Aug 13 '13 at 4:32
    
David beat me to it Copy-Item c:\DirA c:\DirB -recurse –  50-3 Aug 13 '13 at 4:37
    
Ah, I just posted that as an answer. –  Davidw Aug 13 '13 at 4:38
show 4 more comments

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.