1

I am trying to copy a folder from one directory to another in the CMD in Windows 7.

I have found commands for copying individual files:

copy test.txt "C:\NewLocation"

Which works fine. However trying something like this:

copy "C:\Test" "C:\NewLocation"

doesn't work. It wants to take the contents of the directory and move them over. Is there anyway to copy the FOLDER and move it as opposed to the entire directory contents?

Thanks.

Kyle Wright
  • 520
  • 2
  • 9
  • 23

3 Answers3

2

Use xcopy instead of copy:

xcopy "C:\Test" "C:\NewLocation" /s /e

source

Community
  • 1
  • 1
phiresky
  • 406
  • 4
  • 15
  • Okay this works. However I don't know how to choose a specific directory? If I wanted to copy a folder in my C: it seems like this would copy EVERY folder, yes? The source (first input) is not pointing to the directory I need to copy but the parent directory of the directory I need to copy. – Kyle Wright Jul 31 '13 at 18:24
  • 1
    Not exactly sure what you mean, but if you want the contents of "C:\Test" you could use "C:\Test\\*" – phiresky Jul 31 '13 at 18:27
  • If "Test" contained two folders "1" and "2" I don't see how I could copy "1" without copying "2". Unless I'm missing something basic here. If I typed your example, it would copy "1" and "2". – Kyle Wright Jul 31 '13 at 20:06
  • 1
    weeell why how is the computer supposed to know which one to copy? how about xcopy "C:\Test\1" "C:\NewLocation" /s /e – phiresky Jul 31 '13 at 20:11
  • Yeah, that's what doesn't work. It copies the contents of 1, not the folder itself. – Kyle Wright Jul 31 '13 at 21:19
  • 1
    Okay, now I finally understand what exactly you mean. first, do "mkdir C:\NewLocation\1" then, xcopy "C:\Test\1" "C:\NewLocation\1" /s /e – phiresky Jul 31 '13 at 21:23
  • That gives me the same result. I don't see what is different in this example, it's the same thing except you're making the directory that you're about to move it to...? Your example here creates C:\NewLocation\1 then copies the **contents** of C:\Test\1 to C:\NewLocation\1. I would want the end result to have this exist : C:\NewLocation\1\1 because I am putting the folder C:\Test\1 into C:\NewLocation\1. – Kyle Wright Jul 31 '13 at 21:50
  • 1
    @KyleWright wait... why would you want to put it in \1\1? that doesn't make any sense, this command puts the commands into the new folder, which is what you originally wanted – phiresky Jul 31 '13 at 21:52
  • I wanted to copy an existing folder and put it in an existing folder. I'm trying to figure out how to copy folders, not contents. – Kyle Wright Aug 01 '13 at 13:45
  • 1
    Well, I think thats not possible in windows. But whats the difference between copying the folder and creating a new folder, then copying the contents into it? – phiresky Aug 01 '13 at 15:22
1

You can't "copy" folders, but you can "move" them:

move c:\test c:\newlocation
Marc B
  • 356,200
  • 43
  • 426
  • 500
1

You could use xcopy:

xcopy /S C:\Test C:\NewLocation
Joey
  • 344,408
  • 85
  • 689
  • 683