This was the first Google search for batch file copy file to all subfolders .
Here is a way with xcopy . There is also Robocopy, but that would be too powerful for a simple task like this. (I used this to backup the entire drive because it can use multithreading)
But let's focus on xcopy .
This example is for saving to a file with the extension .bat . Just drop the extra % where there are two if they run directly on the command line.
cd "D:\Software\destinationfolder" for /r /d %%I in (*) do xcopy "C:\temp\file.ext" "%%~fsI" /H /K
cd "D:\Software\destinationfolder" change the directory to the folder where you want to copy the file. Wrap this in quotation marks if the path has spaces.for loop - see help here . Or type for/? on the command line./r - iterate over files (recurse subfolders)/d - loop through several folders%%I - %%parameter : replaceable parameterxcopy - Type xcopy/? on the command line for a lot of help. You may need to press Enter to read all the help on this.C:\temp\file.ext - the file you want to copy"%%~fsI" - extends %%I to the full path with only short names/H - Copy files with hidden and system file attributes. By default, xcopy does not copy hidden or system files/K - copies files and saves the read-only attribute in the destination files, if present in the source files. By default, xcopy removes the read-only attribute.
The last two options are just examples if you are having problems with any read-only files and they preserve the most important file properties.
There are many xcopy options here
xcopy examples here
Just for completeness. In this example below, the same file will be copied to each folder in the current directory, not any subfolders. Just the /r option is removed so that it behaves like this.
for /d %%I in (*) do xcopy "C:\temp\file.ext" "%%~fsI" /H /K
source share