It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
Hi guys,

Is there any program you know of that will copy a single file to every sub-folder in a huge directory?


I'm not hugely familiar with command line programs, but could probably figure it out given directions if necessary.

Thanks.
This question / problem has been solved by ZFRimage
avatar
djdarko: Hi guys,

Is there any program you know of that will copy a single file to every sub-folder in a huge directory?

I'm not hugely familiar with command line programs, but could probably figure it out given directions if necessary.

Thanks.
I quickly wrote this for you. Here you go:

(rename copyall.jpg to copyall.bat, since I can only attach pictures).

To use:
_Save copyall.bat to the same folder as the file you want to copy
_Open command prompt and navigate to the required folder
_Run copyall.bat with the file name as parameter.
(e.g. if the file name is called example.doc, you will type the following without the quotes: "copyall.bat example.doc")

(NOTE: this will copy the file to all subfolder and all their subfolders too)

For reference, this is the code I used:

for /r "%CD%" %%f in (.) do (
copy %1 "%%~ff" > nul
)

EDIT:
I'm assuming you're running Windows. Also, let me know if you need any further instructions.
Attachments:
Post edited May 21, 2015 by ZFR
It worked! Thanks.
Post edited May 21, 2015 by djdarko
avatar
djdarko: Yes running windows.

Where should my empty folder destinations be placed? in the same folder as the .bat ?
yes


So if you want to copy example.doc to all the subfolders of c:\test

Then:
_Copy the batch file to c:\test
_Copy example.doc to c:\test
_Run as above


This will copy example.doc to c:\test\folder1 c:\test\folder2 c:\test\folder1\subfolder1a ... etc.
avatar
djdarko: Yes running windows.

Where should my empty folder destinations be placed? in the same folder as the .bat ?
avatar
ZFR: yes

So if you want to copy example.doc to all the subfolders of c:\test

Then:
_Copy the batch file to c:\test
_Copy example.doc to c:\test
_Run as above

This will copy example.doc to c:\test\folder1 c:\test\folder2 c:\test\folder1\subfolder1a ... etc.
One other question:

Any way to make this work for only sub-folders?
Post edited May 21, 2015 by djdarko
avatar
djdarko: One other question:

Any way to make this work for only sub-folders?
You mean without going into subfolders of subfolders?

Like this:

for /d %%f in (*) do (
copy %1 "%%~ff" > nul
)
Attachments:
copy2.jpg (1 Kb)