Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to copy files when ftp complete

Status
Not open for further replies.

mydisney

Programmer
May 7, 2007
55
US
I have code that retrieves files at a client site. Once the files been retrieved I need to copy the same files to a backup directory. How do I do this and where should the code go? Thank you. Here is the code I have:

' VBScript FTP Download from St Paul Travellers
Option Explicit
Dim objFSO, objMyFile, objShell, strFTPScriptFileName, strFilePut
Dim strLocalFolderName, strFTPServerName, strLoginID
Dim strPassword, strFTPServerFolder

'Set FTP options
strLocalFolderName = "c:\mylocalfolder"
strFTPServerName = "ftp.myclient.com"
strLoginID = "myuserid"
strPassword = "mypassword"
strFTPServerFolder = "myremotefolder"

'Set File name
strFilePut = "*.asc"

'Generate FTP command
strFTPScriptFileName = strLocalFolderName & "\FTPScript.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

If (objFSO.FileExists(strFTPScriptFileName)) Then
objFSO.DeleteFile (strFTPScriptFileName)
End If

Set objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True)
objMyFile.WriteLine ("open " & strFTPServerName)
objMyFile.WriteLine (strLoginID)
objMyFile.WriteLine (strPassword)
objMyFile.WriteLine ("cd " & strFTPServerFolder)
objMyFile.WriteLine ("bin")
objMyFile.WriteLine ("lcd " & strLocalFolderName)
objMyFile.WriteLine ("prompt")
objMyFile.WriteLine ("mget " & strFilePut)
??? insert code to move to the backup directory here ????
objMyFile.WriteLine ("disconnect")
objMyFile.WriteLine ("bye")
objMyFile.Close

Set objFSO = Nothing
Set objMyFile = Nothing

'Run ftp script
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run ("ftp -s:" & chr(34) & strFTPScriptFileName & chr(34))
Set objShell = Nothing
 
objShell.Run "path to exe", 1, True

where True means to wait for the thread you ahve started before the next line in your script is executed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top