J.R. Sitman
asked on
Need a script to copy files from a local drive to a folder at another location
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\Pa w_Palace"
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\Pa
ASKER
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.Fi leSystemOb ject")
objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True
WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
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.Fi
objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True
WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
You probably need quotes around the paths:
strFolderPath = Chr(34) & strSource & "\" & strFolderName & Chr(34)
/gustav
strFolderPath = Chr(34) & strSource & "\" & strFolderName & Chr(34)
/gustav
ASKER
I think you misunderstood. The script I posted works fine. I need a new one
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
objFSO.CopyFile SourcePath, DestinationPath
where both parameters are the full path/file names, for you like: \\server\folder\filename
/gustav
ASKER
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\pa wpalace"
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True
WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
Option Explicit
Dim strSource, strDest, strFolderName, strFolderPath
Dim objFSO
strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pa
Set objFSO = CreateObject("Scripting.Fi
objFSO.CopyFolder strFolderPath, strDest & "\" & strFolderName, True
WScript.Echo strFolderPath & " copied to " & strDest & "\" & strFolderName
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 & "\"
/gustav
Seems right.
Include strFile in the Dim line. And remove strFolderName, strFolderPath.
/gustav
Include strFile in the Dim line. And remove strFolderName, strFolderPath.
/gustav
ASKER
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.Fi leSystemOb ject")
strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pa wpalacebac kup"
strFile = "pp.mdb"
objFSO.CopyFile strSource & "\" & strFile, strDest & "\"
WScript.Echo strSource & "\" & strFile & " copied to " & strDest & "\"
Option Explicit
Dim strSource, strDest, strFile
Dim objFSO
Set objFSO = CreateObject("Scripting.Fi
strSource = "\\client\c$\pawpalace"
strDest = "\\databases\access2015\pa
strFile = "pp.mdb"
objFSO.CopyFile strSource & "\" & strFile, strDest & "\"
WScript.Echo strSource & "\" & strFile & " copied to " & strDest & "\"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect. Thanks very much for doing this.
You are welcome!
/gustav
/gustav
ASKER
Can a message be added that tells them when it is complete?
Yes, append this line:
MsgBox "Two files copied.", 64, "File Copy"
/gustav
MsgBox "Two files copied.", 64, "File Copy"
/gustav
ASKER
Worked.
Thanks again
Thanks again
Have a nice weekend!
/gustav
/gustav
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