Page 1 of 1

copy files within multiple directories

Posted: 01 Apr 2009 11:15
by AnthonyCSC
Hi Dos Gurus,
I need some help to copy a file from indir to archivedir folder.
The directory structure is as follows:
C:\Test\000001\indir
C:\Test\000001\archivedir

C:\Test\000004\indir
C:\Test\000004\archivedir

C:\Test\000011\indir
C:\Test\000011\archivedir

C:\Test\000012\indir
C:\Test\000012\archivedir

C:\Test\000040\indir
C:\Test\000040\archivedir

and so on...
000001, 000004, 0000011, 000012, 000040 etc., are directories each one assigned to one specific user. And these directories can vary in numbers as they may grow in the future.

My requirement is scan through all the indir for *.csv files and copy them to their respective archivedir folder.

Please advise how do I write a program to achieve this and thanks for your valuable time and help.

Posted: 01 Apr 2009 11:57
by avery_larry
Think this should do it:

Code: Select all

for /d %%a in (c:\test\*) do copy "%%a\indir\*.csv" "%%a\archivedir\"

Posted: 01 Apr 2009 12:18
by AnthonyCSC
What can I say !
You are a GENIUS !
Thanks a lot.