Solved

Need a script to copy files from a local drive to a folder at another location

Posted on 2016-10-06
18
70 Views
Last Modified: 2016-10-07
We use Citrix server from our remote location to access files at our LA office.  When on Citrix I need to copy two files or the entire folder from the local computer to a folder in LA.  
I tried modifying an existing script (that I didn't write and don't know how to) but it didn't work.  Below is the source and path I need.

strSource = "\\client\c$\paw_palace"
strDest = "\\databases\access2015\Paw_Palace"
0
Comment
Question by:J.R. Sitman
[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
  • 9
  • 9
18 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833041
As you don't reveal your secret script, you can study one that works the other way round:

Deploy and update a Microsoft Access application in a Citrix environment

It should be nothing more than reduce it to the copying part and reverse the local and remote folder.

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833621
That script I'm sure is great, but completely over my head.   Below is what we currently use to copy photos from a local folder to a folder over our network.  All I want to do is copy two files from a local folder to a remote folder.  

I tried changing this script but it doesn't work.   I think because of the portion of the code that uses monthname.

How do I modify this code or can you create one for me, please?


Option Explicit
Dim strSource, strDest, strFolderName, strFolderPath
Dim objFSO

strSource = "\\client\c$\photos"
strDest = "\\fileserver\community files\Public Files\Pet-Ark"

strFolderName = Right("0" & Day(Date), 2) & _
    MonthName(Month((Date))) & Year(Date) & "-SB"
   
   
strFolderPath = strSource & "\" & strFolderName


Set objFSO = CreateObject("Scripting.FileSystemObject")


objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True


WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833657
You probably need quotes around the paths:

strFolderPath = Chr(34) & strSource & "\" & strFolderName & Chr(34)

/gustav
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:J.R. Sitman
ID: 41833851
I think you misunderstood.  The script I posted works fine.  I need a new one
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833877
Oh, then you use the CopyFile method:

    objFSO.CopyFile SourcePath, DestinationPath

where both parameters are the full path/file names, for you like: \\server\folder\filename

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833887
Below is the script I'm trying to get to work.  Would you please modify it for me?  

Option Explicit
Dim strSource, strDest, strFolderName, strFolderPath
Dim objFSO

strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pawpalace"

Set objFSO = CreateObject("Scripting.FileSystemObject")


objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True


WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
0
 

Author Comment

by:J.R. Sitman
ID: 41833891
I get this

script.png
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833901
It could be:
Option Explicit
Dim strSource, strDest, strFolderName, strFolderPath
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pawpalace"
strFile = "YourFile.png"

objFSO.CopyFile strSource & "\" & strFile,  strDest & "\"

WScript.Echo strSource & "\" & strFile & " copied to " & strDest & "\"

Open in new window

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833911
got this

script2.png
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833918
Seems right.
Include strFile in the Dim line. And remove strFolderName, strFolderPath.

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833931
That worked.   How do I have it copy two files?   My test is currently only one.  see working script

Option Explicit
Dim strSource, strDest, strFile
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pawpalacebackup"
strFile = "pp.mdb"

objFSO.CopyFile strSource & "\" & strFile,  strDest & "\"

WScript.Echo strSource & "\" & strFile & " copied to " & strDest & "\"
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41833939
Well, just run the command twice:
Option Explicit
Dim strSource, strDest, strFile, strFile2
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pawpalacebackup"
strFile = "pp.mdb"
strFile2 = "pp2.mdb"

objFSO.CopyFile strSource & "\" & strFile,  strDest & "\"
objFSO.CopyFile strSource & "\" & strFile2,  strDest & "\"

Open in new window

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833951
Perfect.  Thanks very much for doing this.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41833956
You are welcome!

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41833999
Can a message be added that tells them when it is complete?
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41834008
Yes, append this line:

    MsgBox "Two files copied.", 64, "File Copy"

/gustav
0
 

Author Comment

by:J.R. Sitman
ID: 41834023
Worked.

Thanks again
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41834099
Have a nice weekend!

/gustav
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article runs through the process of deploying a single EXE application selectively to a group of user.
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

756 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