older_than_a_week.ftp
This script deletes every remote file older than a week.
# Connecto to the FTP server OPENHOST("ftp.myhost.com","antonia","123456") # Change current remote directory CHDIR("/directorytobeprocessed") # Retrieve current date and time $current_date_time=GETDATE(FORMAT0) PRINT("Current date and time is ".$current_date_time) # Substract a week (in seconds) from the current date, # assign the result to another variable $a_week_ago=$current_date_time-(7*24*60*60) PRINT("A week ago was ".$a_week_ago) PRINT("Every file older than this will be deleted from the FTP server") # Request the remote file list GETLIST($remote_file_list,REMOTE_FILES) # For each file in the current remote directory # check if it is older than a week. If so delete it FOREACH $remote_file IN $remote_file_list $file_last_modification_time=GETFILETIME(REMOTE,$remote_file) IF($file_last_modification_time < $a_week_ago) DELETEFILE($remote_file) END IF END FOREACH CLOSEHOST