xcopy only copy subdirectories with their contents

3

1

As the title says...

An example: I have these files & dirs:

c:\file.txt  
c:\a\somefile.txt  
c:\b\anotherfile.txt

And with some magic I want this structure on the destination:

d:\a\somefile.txt  
d:\b\anotherfile.txt

Can this be done with xcopy?

Stormenet

Posted 2010-12-20T11:59:00.233

Reputation: 173

Answers

7

Yes:

C:\> FOR /D %d in (*) DO xcopy /S /I %d d:\%d
  • /D : Just directories
  • /S : Copy subdirectories
  • /I : Targets are directory (not file)

:-)

Ehsan

Posted 2010-12-20T11:59:00.233

Reputation: 296