Page 1 of 1

copy one file to all subfolder

Posted: 14 Oct 2013 07:26
by taherkhani
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

.
.
.

Re: copy one file to all subfolder

Posted: 14 Oct 2013 08:23
by dwngrt
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\*\*

Re: copy one file to all subfolder

Posted: 14 Oct 2013 11:02
by aGerman
Untested:

Code: Select all

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

Regards
aGerman