Script to Copy a folder to multiple destination folders
This script is useful if you wish to copy a folder and its contents to multiple destination folders such as user areas.. This code is for a batch file, so when you create the file in notepad you will need to save it with the extension .bat and not .txt
Here is an explaination to help you understand whats happening. I have three users with folder locations:
C:\users\user1
C:\users\user2
C:\users\user3
I want the a folder called examples located c:\examples to be copied into each of them.
So i replace the <dir location of where you want to copy the folder to> with c:\users\
I change the <source directory> to c:\examples
and i change the name of what the <name of directory to be place in> to the name of the directory. So that becomes examples. I then run the file once its saved as a bat. Below is the code. The result is the examples folder and all subdirectories copied to the users 1 to 3 folders.
The Code
for /f %%j in ('dir /B /AD <dir location of where you want to copy the folder to>\*.*') do (
xcopy /s <source Directory> <dir location of where you want to copy the folder to>\%%j\ <Name of Directoy to be place in>
rem doesnt work with spaces in the folder names %%j
pause
MyPCHealth