copy files within multiple directories

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
AnthonyCSC
Posts: 4
Joined: 01 Apr 2009 10:47

copy files within multiple directories

#1 Post by AnthonyCSC » 01 Apr 2009 11:15

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.

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 01 Apr 2009 11:57

Think this should do it:

Code: Select all

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

AnthonyCSC
Posts: 4
Joined: 01 Apr 2009 10:47

#3 Post by AnthonyCSC » 01 Apr 2009 12:18

What can I say !
You are a GENIUS !
Thanks a lot.

Post Reply