3

I need to copy folder structure without files except for one sub-folder. That is I want to copy the folder structure without files plus only one of the sub-folder to be copied with its content.

I can accomplish folder structure copy using

xcopy /t /e "source folder" "destination folder"

But I want a folder like data in source folder to be copied with its content to destination folder. I have to do it with a single line of code. Is that possible?

3
  • and why is adding another xcopy command after the first one bad? stackoverflow.com/questions/8055371/…
    – akira
    Commented Nov 27, 2013 at 6:45
  • I am not saying it is bad. I just asked, can it be accomplished in a single line?
    – DDK
    Commented Oct 15, 2014 at 13:10
  • Be very careful of the destination folder when using robocopy SOURCE DESTINATION /mir /xd FOLDER_TO_EXCLUDE It mirrors everything from source to destination so if you already have some other files in the destination that are not present in source, they will get purged. Not even going to recycle bin, completely deleted. I just managed to permanently delete a bunch of useful files. GG
    – Tony
    Commented Nov 19, 2021 at 15:54

1 Answer 1

6

Use robocopy:

robocopy SOURCE DESTINATION /mir /xd FOLDER_TO_EXCLUDE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .