Script to copy a folder to multiple folders
Posted on 2016-11-08
I'd be grateful for your assistance please in creating a script to copy a folder to the application data folder of multiple users. The users have a homedrive located on server1 and I would like to copy a folder the application data folder within their homedrives.
I would like to copy a folder called Folder1 on \\server1\e$\Users\Students\ to \\server1\e$\Users\Students\2016Intake\%USERS%\Application Data\
I'm not sure of this is the most efficient method to do this but I have created a robocopy script to do this, however I cannot seem to find out how %USERS% can be represented with a wildcard. I have managed to export the names of the folders within 2016Intake into a txt file so maybe I could 'call' these.
If I user %USERNAME% as a wildcard the script will create a folder on \\server1\e$\Users\Students\2016Intake\ with my username.
My robocopy script so far looks like this:
robocopy "\\server1\e$\Users\Students\Folder1" "\\server1\e$\Users\Students\2016Intake\%USERS%\Application Data\" /MIR
I have tried replacing %USERS% with **, *.*, %%A etc but the script will only create a folder within the 2016Intake folder, whereas I am trying to copy the folder to the Application Data folder of these users.
Hopefully this makes sense.
Thanks in advance