Solved

Copy files to multiple locations

Posted on 2011-09-20
4
455 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 500 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
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…

734 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