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?
I want to check each file download
and if the size is bigger of 10 megs delete them
How can i do that ?

This is my script
FTP Script
  1. $result=OPENHOST("some host","usename","password")
  2.  
  3. SETTYPE(BINARY)
  4.  
  5.  
  6. IF($result!="OK")
  7.     STOP
  8.  
  9. $result=LOCALCHDIR("D:\dnews\BAG\temp")
  10. IF($result!="OK")
  11.     STOP
  12.  
  13. $result=CHDIR("uucp_bag_files/outgoing")
  14. IF($result!="OK")
  15.     STOP
  16.  
  17. $result=GETLIST($list,REMOTE_FILES,"*.gz")
  18. IF($result!="OK")
  19.     STOP
  20.  
  21. FOREACH $item IN $list
  22.     $result=GETFILE($item)
  23.     IF($result=="OK")
  24.         DELETEFILE($item)
  25.     ELSE
  26.         STOP
  27.     END IF
  28.  
  29.  
  30.  
  31. EXEC("d:\utl\un-gzip.bat")
Hello Floffy,

Try the following:
FTP Script
  1. FOREACH $item IN $list
  2.     $filezise_in_bytes=GETFILESIZE(REMOTE,$item)
  3.     $filesize_in_mb=($filesize_inbytes/1024)/1024
  4.     $result=GETFILE($item)
  5.     IF($result=="OK" AND  $filesize_in_mb>10)
  6.         DELETEFILE($item)
  7.     ELSE
  8.         STOP
  9.     END IF
I use a News server and some of my feed use Bag files to exchange feed
one of my use is to grab them by FTP the Files are *.gz
FTP Script
  1. # Connect to FTP server
  2. $result=OPENHOST("ftp.localhost.test","usename","password")
  3.  
  4. # Log every time a different files with time/date
  5. LOGTO("D:\scriptftp-".GETTIME(FORMAT2).".txt")
  6.  
  7. SETTYPE(BINARY)
  8. VERBOSE(ON)
  9.  
  10.  
  11. # Check the connection if OK, if not stop the script
  12. IF($result!="OK")
  13.  
  14. # Check local DIRectorie if exit if soo change to
  15. $result=LOCALCHDIR("D:\dnews\BAG\temp")
  16. IF($result!="OK")
  17.    STOP
  18.  
  19. # Check remote DIRectorie if exit if soo change to
  20. $result=CHDIR("uucp_bag_files/outgoing")
  21. IF($result!="OK")
  22.    STOP
  23.  
  24. # Check if *.gz files exist if not stop
  25. $result=GETLIST($list,REMOTE_FILES,"*.gz")
  26. IF($result!="OK")
  27.    STOP
  28.  
  29. # Check the Size if each files if bigger 10 megs delete and do not dowload
  30. FOREACH $item IN $list
  31.  
  32.     $FLAG=0
  33.     $filezise_in_bytes=GETFILESIZE(REMOTE,$item)
  34.     IF($filezise_in_bytes>10480000)
  35.         DELETEFILE($item)
  36.         $FLAG=1
  37.     END IF
  38.  
  39.  IF ($FLAG==0)
  40.     $result=GETFILE($item)
  41.     IF($result=="OK")
  42.         DELETEFILE($item)
  43.     ELSE
  44.         STOP
  45.     END IF
  46.  
  47.  
  48.  
  49. # exec External BAT files
  50.  
  51. EXEC("d:\utl\un-gzip.bat")
  52.  
  53. EXEC("d:\utl\hours.bat")
Thanks for submitting such a nice script Floffy. Other users may find it useful.