copy one file to all subfolder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taherkhani
Posts: 24
Joined: 07 Dec 2012 04:33

copy one file to all subfolder

#1 Post by taherkhani » 14 Oct 2013 07:26

hi

i have file 'run.bat' in folder D:\math, and i want copy this file to all subfolder math.

subfolder like this:

d:\math\1103\[86]-1103-math
d:\math\1103\[87]-1103-math
d:\math\1103\[88]-1103-(A)-math
d:\math\1103\[89]-1103-3001-math
d:\math\1103\[90]-1103-(B)-math

d:\math\1105\[86]-1105-math
d:\math\1105\[87]-1105-math
d:\math\1105\[88]-1105-(B)-math
d:\math\1105\[89]-1105-5018-(E)-math
d:\math\1105\[90]-1105-(C)-math
d:\math\1105\[91]-1105-(A)-math
d:\math\1105\[92]-1105-math

.
.
.

dwngrt
Posts: 26
Joined: 07 Oct 2013 05:14
Location: The Netherlands

Re: copy one file to all subfolder

#2 Post by dwngrt » 14 Oct 2013 08:23

do you want the script to copy something else to all the sub-folders or do you want the script to copy itself to all the subfolders?

maybe this may help you:

Code: Select all

XCOPY file.extension d:\math\*\*

aGerman
Expert
Posts: 4705
Joined: 22 Jan 2010 18:01
Location: Germany

Re: copy one file to all subfolder

#3 Post by aGerman » 14 Oct 2013 11:02

Untested:

Code: Select all

for /d /r "d:\math" %%i in (*-math) do copy "myfile.ext" "%%~i\"

Regards
aGerman

Post Reply