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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP attempt to delete a file *only* if it already exists

Status
Not open for further replies.

dgr7

IS-IT--Management
Dec 29, 2006
43
US
hello,
I have this below .vbs script code that I use to delete two files from an FTP site. Sometimes one or both of the below files (LTRDOWN01 and CABCALLS.txt) doesn't exist, so that when the vbs code is executed an error occurs. How can I modify the code so that each Remove statement is executed *only* if the file exists?
thanks in advance,
david
---------------------------
' VBS Script Generated by CuteFTP (TM) macro recorder.
' Generated, then edited: 02/07/07 by dgr.

' Create TEConnection object
Set MySite = CreateObject("CuteFTPPro.TEConnection")

' Initialize remote server host name, protocol, port, etc.
MySite.Host = "192.168.1.1"
MySite.Protocol = "FTP"
MySite.Port = 21
MySite.Retries = 34
MySite.Delay = 7
MySite.MaxConnections = 4
MySite.TransferType = "ASCII"
MySite.DataChannel = "DEFAULT"
MySite.AutoRename = "OFF"
' WARNING!!! SENSITIVE DATA: user name and password.
MySite.Login = "****"
MySite.Password = "***"
MySite.SocksInfo = ""
MySite.ProxyInfo = ""
' Connect to remote server
MySite.Connect
MySite.RemoteRemove "/u/sting/tapefiles/LTRDOWN01"
MySite.RemoteRemove "/u/sting/tapefiles/CABCALLS.txt"
MySite.Disconnect
 
something like this ?
If MySite.RemoteExists("/u/sting/tapefiles/LTRDOWN01") Then
MySite.RemoteRemove "/u/sting/tapefiles/LTRDOWN01
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OOps, sorry for the typo:
If MySite.RemoteExists("/u/sting/tapefiles/LTRDOWN01") Then
MySite.RemoteRemove "/u/sting/tapefiles/LTRDOWN01"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yes, that worked well, thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top