ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Post here if you experience file transfer problems or unexpected errors.
When I run this script it deletes the files that have bee uploaded in the remote server, not the files that were copied from local drive, which should be the correct ones to be deleted.
FTP Script
  1. CHDIR("/archive")
  2. PUTFILE("path")
  3. LOCALCHDIR("path")
  4. $result=GETLIST($local_file_list,LOCAL_FILES,"*.zip")
  5.  
  6. IF($result!="OK")
  7.     STOP
  8. # Retrieve current date and time
  9. $current_date_time=GETDATE(FORMAT0)
  10.  
  11. PRINT("Current date and time is ".$current_date_time)
  12.  
  13. # Substract two days (in seconds) from the current date,
  14. # assign the result to another variable
  15. $two_days_ago=$current_date_time-(2*24*60*60)
  16.  
  17. PRINT("two days ago was ".$two_days_ago)
  18. PRINT("Every file older than this will be uploaded to the FTP server")
  19.  
  20. # Request the remote file list
  21.  
  22.    
  23.  
  24.  
  25. # For each file in the current local directory
  26. # check if it is older than two days. If so upload it
  27. FOREACH $local_file IN $local_file_list
  28.     $file_last_modification_time=GETFILETIME(LOCAL,$local_file)
  29.     IF($file_last_modification_time<$two_days_ago)
  30.    
  31.     $result=PUTFILE($local_file)
  32.            
  33.     IF($result=="OK")
  34.         #EXEC("del".$local_file)
  35.         DELETEFILE($local_file)
  36.            
  37.     END IF
  38.      
  39.      
  40.     END IF
  41.  
If you want to delete the local files you have to replace this:
FTP Script
  1. IF($result=="OK")
  2. #EXEC("del".$local_file)
  3. DELETEFILE($local_file)
with this:
FTP Script
  1. IF($result=="OK")
  2. EXEC("del ".$local_file)