Does anyone know of a way to login to an ftp server and delete files older than x amount of days? I know how to do it with regular folders (c:\temp, etc) by using a function but I'm not sure how it would work on an ftp server where I can't specify a drive letter and folder. Any ideas are greatly appreciated.
Check out the WinInet extender's iFtpCmd (MDTM command) and iFtpDelete functions. Not aware of any working examples but will check around and post if I find something.
Here is quick and dirty example that does some of what you require. It gets the modify time of a file and deletes it, if it wasn't modified today:
AddExtender("WWINT44I.DLL")
UserId="me"
Pswd="*topsecret*"
SERVER="my.server.com"
tophandle=iBegin(0,"","")
conhandle=iHostConnect(tophandle,SERVER,@FTP, userid,pswd)
If conhandle==0
Message("ERROR","Unable to connect to host")
Exit
EndIf
; Get the modify date.
strTime = iFtpCmd(conhandle, 'MDTM', 'test.txt', @ASCII)
; Cleanup result - exactly how depends on server's return info.
strTime = ItemExtract( 1, ItemExtract(2, strTime, ' '), @CR)
nResult = 0
if strTime < '20160113000000' ; If it wasn't modified today.
nResult = iFtpDelete(conhandle, 'test.txt')
endif
Message("File Deleted?", nResult)
iClose(conhandle)
iClose(tophandle)
Thanks, that is helpful. I was hoping to find a way to check all files and delete only those that were x amount of days old.
Check out the iFtpFindInit and iFtpFindNext functions in the Consolidated WIL Help file. You use them to create a list of files that meet your date criteria because iFtpFindNext returns create and modification date information.
I completely forgot about iFtpFindNext's ability to retrieve create date information...