Vbscript将文件夹复制到FTP服务器列表

时间:2016-06-09 08:13:48

标签: vbscript ftp

您好我有以下脚本



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
&#13;
&#13;
&#13;

有人可以请求如何制作它,以便我可以提供一个源列表,并将文件夹复制到FTP服务器。另外如何修复仍然发生的覆盖确认弹出窗口,即使拷贝类型设置为16

0 个答案:

没有答案