Copying Directories

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
td6k
Posts: 2
Joined: 27 Jul 2010 07:59

Copying Directories

#1 Post by td6k » 27 Jul 2010 08:07

Hi!
I have some directories in like these:

27-07-2010 14:15 <DIR> .
27-07-2010 14:15 <DIR> ..
27-07-2010 14:15 <DIR> 080_D03
27-07-2010 14:15 <DIR> 080_D04
27-07-2010 14:14 <DIR> 080_D05
27-07-2010 14:14 <DIR> 080_D06
27-07-2010 14:14 <DIR> 080_D07
27-07-2010 14:14 <DIR> 080_D08
27-07-2010 14:14 <DIR> 080_D09
27-07-2010 14:14 <DIR> 080_D10
27-07-2010 14:14 <DIR> 081_D01
27-07-2010 14:14 <DIR> 081_D02
27-07-2010 14:14 <DIR> 081_D03
27-07-2010 14:14 <DIR> 081_D04
27-07-2010 14:14 <DIR> 082_D01
27-07-2010 14:14 <DIR> 082_D02
27-07-2010 14:14 <DIR> 082_D03
27-07-2010 14:14 <DIR> 082_D04
27-07-2010 14:14 <DIR> 083_D01
27-07-2010 14:14 <DIR> 083_D02
27-07-2010 14:14 <DIR> 083_D03
27-07-2010 14:14 <DIR> 083_D04
27-07-2010 14:14 <DIR> 083_D05
27-07-2010 14:14 <DIR> 083_D06
27-07-2010 14:14 <DIR> 083_D07
27-07-2010 14:14 <DIR> 083_D08
27-07-2010 14:14 <DIR> 083_D09
27-07-2010 14:14 <DIR> 083_D10
27-07-2010 14:14 <DIR> 083_S09
27-07-2010 14:14 <DIR> 084_D01
27-07-2010 14:14 <DIR> 084_D02
27-07-2010 14:14 <DIR> 084_D03
27-07-2010 14:14 <DIR> 084_D04
27-07-2010 14:14 <DIR> 084_D05
27-07-2010 14:14 <DIR> 084_D06
27-07-2010 14:14 <DIR> 084_D07
27-07-2010 14:14 <DIR> 084_D08
27-07-2010 14:14 <DIR> 084_D09
27-07-2010 14:14 <DIR> 084_D10
27-07-2010 14:15 <DIR> 084_S09
27-07-2010 14:15 <DIR> 085_D01
27-07-2010 14:15 <DIR> 085_D02
27-07-2010 14:15 <DIR> 085_D03
27-07-2010 14:15 <DIR> 085_D04
27-07-2010 14:15 <DIR> 085_D05
27-07-2010 14:15 <DIR> 085_D06
27-07-2010 14:15 <DIR> 085_D07
27-07-2010 14:15 <DIR> 085_D08

I want to make a batch file that copies all the *_D08 directories and contents to another dir. Some thing like this:

Xcopy /e ???_D08 c:\SOME_OTHER_DIR

Could someone help me?

Thanks a lot.

Ricardo from Portugal

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Copying Directories

#2 Post by !k » 27 Jul 2010 10:03

Code: Select all

for /f "delims=" %%d in ('dir /ad/b ???_D08') do xcopy /e /i /y "%%d" "c:\SOME_OTHER_DIR\%%d"

td6k
Posts: 2
Joined: 27 Jul 2010 07:59

Re: Copying Directories

#3 Post by td6k » 27 Jul 2010 10:25

Thank you!!!! 8)
It really works! I have never used FOR command in batch files. I´m going to study its syntax.

Thanks for your help!

Post Reply