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.
Need help writing a script? Have any question about ScriptFTP?
Hi all,

i'm using the download and delete script to 'move' files from one site to another.
this works fine, but files that are already downloaded by another FTP program in the past, are still available at the source site.
is there a way to delete all the files at the 'source' site, that are already available at the 'destination' site ?

I now tried
FTP Script
  1. FOREACH $item IN $list
  2.    ADDEXCLUSION(DOWNLOAD, $item)
  3.    DELETEFILE($item)
but this isn't working as expected.
This is my complete script :
FTP Script
  1. # Connect to ftp.myhost.com as myuser
  2. OPENHOST("myftp.com","user","pass")
  3.  
  4. # If OPENHOST failed stop the script
  5. #IF($result!="OK")
  6. #    STOP
  7. #END IF
  8.  
  9. CHDIR("/mpeg2")
  10.  
  11. # Change the current local directory. The files
  12. # will be downloaded here.
  13. $result=LOCALCHDIR("C:\MPEG2")
  14.  
  15. # If LOCALCHDIR failed stop the script
  16. IF($result!="OK")
  17.     STOP
  18. # Exclude files that already exist localy
  19. GETLIST($list, LOCAL_FILES, "*.mpg")
  20.  
  21.  
  22. FOREACH $item IN $list
  23.    ADDEXCLUSION(DOWNLOAD, $item)
  24.    DELETEFILE($item)
  25.  
  26. # Get the remote file listing, store it in $list
  27. $result=GETLIST($list,REMOTE_FILES,"*.mpg")
  28.  
  29. # If GETLIST failed stop the script
  30. IF($result!="OK")
  31.     STOP
  32.  
  33. # For each file in $list...
  34. FOREACH $item IN $list
  35.     # Download the file
  36.     $result=GETFILE($item)  
  37.     # If the file has been succesfully downloaded
  38.     # delete the remote copy. If not stop the script.
  39.     IF($result=="OK")
  40.         DELETEFILE($item)
  41.     ELSE
  42.         STOP
  43.     END IF
  44.  
  45.  
  46. # Close the connection
In my opinion there are a few extra commands, and so should work
FTP Script
  1. # Connect to ftp.myhost.com as myuser
  2. OPENHOST("myftp.com","user","pass")
  3.  
  4. CHDIR("/mpeg2")
  5.  
  6. # Change the current local directory. The files
  7. # will be downloaded here.
  8. $result=LOCALCHDIR("C:\MPEG2")
  9.  
  10. # If LOCALCHDIR failed stop the script
  11. IF($result!="OK")
  12.     STOP
  13.  
  14. # Exclude files that already exist localy
  15. GETLIST($list, LOCAL_FILES, "*.mpg")
  16.  
  17. FOREACH $item IN $list
  18.   DELETEFILE($item)
  19.  
  20. # Get the remote file listing, store it in $list
  21. $result=GETLIST($list,REMOTE_FILES,"*.mpg")
  22.  
  23. # If GETLIST failed stop the script
  24. IF($result!="OK")
  25.     STOP
  26.  
  27. # For each file in $list...
  28. FOREACH $item IN $list
  29.     # Download the file
  30.     $result=GETFILE($item)  
  31.     # If the file has been succesfully downloaded
  32.     # delete the remote copy. If not stop the script.
  33.     IF($result=="OK")
  34.         DELETEFILE($item)
  35.     ELSE
  36.         STOP
  37.     END IF
  38.  
  39.  
  40. # Close the connection
if this is not the case, as before, then paste the command to start
FTP Script
  1. verbose (on)
  2. logto("filename")
and see the result