Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.
delete_partial_downloads.s
When everything is working perfectly (connecting to a well-behaving FTP server over a reliable network), downloading a batch of files can be as simple as:
RCVFILE "*"
However, sometimes you have to work in a less-than-perfect environment where connections drop without warning. This can result in downloading partial files.
This sample script shows a more reliable way to download one file at a time and automatically delete files that only download partially. The script downloads files one at a time from the server, deleting files after they have been successfully downloaded.
WARNING: This script may result in an infinite loop. This is fine if you expect network failures to recover quickly. You may want to use the LOOPCOUNT, LOOPIF, LOOPTO and related commands (see the Help file for more details) to limit the number of retries before aborting the script.
This is not the only way to handle this situation. For example, if you are downloading a very large file, you may not want to start over from scratch if the download fails. In that case, you may want to use the resume feature of Robo-FTP to loop back and try to resume the download at the point of failure. See the Help file entry for RCVFILE for more details on the resume feature.
1 :next
2 FTPLOGON "mysite"
3 FTPGETREWIND
4 FTPGETFILE "*.txt"
5 IFERROR GOTO done
6 RCVFILE %sitefile /delete
7 IFERROR GOTO sitefile_download_failure
8 GOTO next
9 :sitefile_download_failure
10 DELETE %sitefile
11 GOTO next
12 :done

