[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Copy files to multiple locations

Posted on 2011-09-20
4
Medium Priority
?
459 Views
Last Modified: 2012-05-12
Good morning all

I am looking for a script that allows me to copy the contents of one folder to a folder in multiple user areas

for example i have the following folders

c:\users\user1\templates
c:\users\user2\templates
c:\users\user3\templates

and I would like to copy the contents of c:\templates to these locations.  Folder names (user1, user2) in c:\users change on a daily basis .

Many thanks
Forsters
0
Comment
Question by:forsters
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 36565185
Hi, see if this works.

Regards,

Rob.
strSource = "C:\Templates"

If Right(strSource, 1) <> "\" Then strSource = strSource & "\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objFolder In objFSO.GetFolder("C:\Users").SubFolders
	strTemplates = objFolder.Path & "\Templates\"
	If objFSO.FolderExists(strTemplates) = False Then objFSO.CreateFolder(strTemplates)
	objFSO.CopyFile strSource, strTemplates, True
Next

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 36565189
Oops, try this.

Rob.
strSource = "C:\Templates"

If Right(strSource, 1) <> "\" Then strSource = strSource & "\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objFolder In objFSO.GetFolder("C:\Users").SubFolders
	strTemplates = objFolder.Path & "\Templates\"
	If objFSO.FolderExists(strTemplates) = False Then objFSO.CreateFolder(strTemplates)
	objFSO.CopyFile strSource & "*", strTemplates, True
Next

Open in new window

0
 

Author Closing Comment

by:forsters
ID: 36565306
Wonderful works perfectly thanks the for the quick reply

Forsters
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36565828
No problem. Thanks for the grade.

Rob.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question