2

Hi I have the following script

Set oShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Path to file or folder to upload
Source0 = "C:\Users\User\Desktop\Work\CRC01\8BR01547\61000856"

FTPUpload(Source0)


Sub FTPUpload(Source0)

On Error Resume Next

'Copy Options: 16 = Yes to All
Const copyType = 16

'FTP Wait Time in ms
waitTime = 80000
 
FTPUser = "Martin"
FTPPass = ""
FTPHost = "PC247"
FTPDir0 = "/Martin/61000856"


strFTP = "ftp://" & FTPUser & ":" & FTPPass & "@" & FTPHost & FTPDir0 
Set objFTP = oShell.NameSpace(strFTP)

'Make new folder on FTP site
'objFTP.NewFolder "FTP Backup"


'Upload single file       
If objFSO.FileExists(Source0) Then

Set objFile = objFSO.getFile(Source0)
strParent = objFile.ParentFolder
Set objFolder = oShell.NameSpace(strParent)

Set objItem = objFolder.ParseName(objFile.Name)

Wscript.Echo "Uploading file " & objItem.Name & " to " & strFTP
 objFTP.CopyHere objItem, copyType


End If


'Upload all files in folder
If objFSO.FolderExists(Source0) Then

'Code below can be used to upload entire folder
Set objFolder = oShell.NameSpace(Source0)

Wscript.Echo "Uploading folder " & Source0 & " to " & strFTP
objFTP.CopyHere objFolder.Items, copyType

End If


If Err.Number <> 0 Then
Wscript.Echo "Error: " & Err.Description
End If

'Wait for upload
WScript.Sleep waitTime

End Sub

Could someone please help on how to make it so that I can provide a list of sources and it copys the folders over to the FTP server. Also How to I fix the overwrite confirmation popup that still happens even if the copytype is set too 16

Martinn Roelofse
  • 423
  • 2
  • 4
  • 13

0 Answers0