Copy to all folders in batch file?
You can do this by using the command for
with a switch /r
that is used to list the directory tree. For example, this will copy the file C: \ a.jpg to the C: \ Test folder and all of its subfolders:
for /r "C:\Test" %%f in (.) do (
copy "C:\a.jpg" "%%~ff" > nul
)
The operator for /r "C:\Test" %%f in (.)
enumerates the C: \ Test folder and all its subfolders and %%~ff
returns the name of the current folder.
source to share
you can copy the file to all folders of the directory using the following command
for / F% g in ('dir / AD / B / S') DO copy c: \ myfile% g
explanation:
In the above command: -% g is a variable, dir / AD / B / S: - is a command to view all folders and subfolders of a directory, / F: is the switch we used for the command if we want to iterate over the results the command enclosed in a parenthesis (in our case it is ('dir / AD / B / S'), c: \ myfile: is the file that we want to copy in all subfolders
source to share