Multiple sessions in VBScript for uploads?
I have 10 files, about 5 GB each that I need to upload nightly. Doing them with one session (sequentially) takes about 3.5 hours. Transferring each file via GUI simultaneously reduces overall time to about 30 minutes on the relatively high bandwidth connection I have.
I'm trying to figure out how to script the simultaneous transfers. My understanding is that I have to create simultaneous sessions in order to do this, but this code still seems to process sequentially/synchronously. I'm very new at scripting, so perhaps I'm making a fundamental mistake here or making assumptions in how this would work. Any guidance would certainly be appreciated. Thanks in advance!
Set objFolder = objFSO.GetFolder(zipfolder)
Set colFiles = objFolder.Files
For Each objFiles in colFiles
filename=objFiles.Name
Set session(x) = WScript.CreateObject("WinSCP.Session")
session(x).Open sessionOptions
UpdateStatus("Uploading file " & zipfolder & "\" & filename & " to " & DirToCreate & "/")
Set transferResult(x) = session(x).PutFiles(zipfolder & "\" & filename, DirToCreate & "/", False, transferOptions)
x=x+1
Next
' Print results
For y=0 to x
transferResult(y).Check
For Each transfer In transferResult(y).Transfers
'WScript.Echo "Upload of " & transfer.FileName & " succeeded"
UpdateStatus("Upload of file " & transfer.FileName & " succeeded")
Next
' Disconnect, clean up
session(y).Dispose
Next
I'm trying to figure out how to script the simultaneous transfers. My understanding is that I have to create simultaneous sessions in order to do this, but this code still seems to process sequentially/synchronously. I'm very new at scripting, so perhaps I'm making a fundamental mistake here or making assumptions in how this would work. Any guidance would certainly be appreciated. Thanks in advance!
Set objFolder = objFSO.GetFolder(zipfolder)
Set colFiles = objFolder.Files
For Each objFiles in colFiles
filename=objFiles.Name
Set session(x) = WScript.CreateObject("WinSCP.Session")
session(x).Open sessionOptions
UpdateStatus("Uploading file " & zipfolder & "\" & filename & " to " & DirToCreate & "/")
Set transferResult(x) = session(x).PutFiles(zipfolder & "\" & filename, DirToCreate & "/", False, transferOptions)
x=x+1
Next
' Print results
For y=0 to x
transferResult(y).Check
For Each transfer In transferResult(y).Transfers
'WScript.Echo "Upload of " & transfer.FileName & " succeeded"
UpdateStatus("Upload of file " & transfer.FileName & " succeeded")
Next
' Disconnect, clean up
session(y).Dispose
Next