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 have a folder with a lot of subfolders and files in them. Is there a way to copy the folder and subfolders directory structure without copying the files they contain, using cmd or powershell?

share|improve this question
add comment

5 Answers

Yup. XCOPY

XCopy source {destination}  /t

example

xcopy C:\Folders D:\Folders /t

more about xcopy can be found here http://ss64.com/nt/xcopy.html

share|improve this answer
    
Lol. I knew there was something simpler. –  Ariane Jan 8 '13 at 21:47
add comment

If you want to copy empty folders as well.

xcopy C:\Folders D:\Folders /t /e

share|improve this answer
add comment

There's probably a better solution, but I'd see these:

  • Copy everything, then empty the folders with a script.

  • Make a script that will copy everything if it has no extension. Unless you have files without an extension in the folders, which you shouldn't, it should work, because, well. Folders don't have extensions. Something that would look like this in pseudocode:

open_directory($path);
while($file=get_directory_content) {
if(empty(get_file_extension($file))) {
copy_the_file($file,$destination);
}
}
close_directory;

share|improve this answer
    
Unfortunatelly, we do have files without extensions. From .placeholders for code repos, to some specific data files. –  ldigas Jan 9 '13 at 7:00
    
Oh. Well. Maybe there's an if(it's a folder) thing, then. But uhm. The xcopy thing above seems like it's the right thing for you then. Unless it's not, in which case you can run a script to 1. copy all folders and 2. empty all folders. Or something. But this is... Long. xD –  Ariane Jan 9 '13 at 7:19
add comment

as far as I know there are third party software which may provide this functionality if you want to do with command prompt then copy command is out there. type help copy in cmd which provides details on how you copy files through cmd.
after copying go to the folder through cmd and run command

del*.*
which deletes files because folders not having . character

share|improve this answer
1  
Deletes files all right, but who says folder names cannot contain a dot/period as well? –  Karan Jan 9 '13 at 18:11
add comment

Look at 47folders app, free, handy Windows tool, does exactly what you need through nice GUI. enter image description here

share|improve this answer
add comment

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.