Page 1 of 1

Copying Directories

Posted: 27 Jul 2010 08:07
by td6k
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

Re: Copying Directories

Posted: 27 Jul 2010 10:03
by !k

Code: Select all

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

Re: Copying Directories

Posted: 27 Jul 2010 10:25
by td6k
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!