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_old_files.s
Robo-FTP is often used to perform clean-up duties on remote or local folders. This sample script scans a local directory and deletes all files older than 30 days. This technique could be used for log rotation, for example.
1 WORKINGDIR "c:\folder\to\clean"
2 SET temp = %datetime
3 DATETIMESUB temp 30 /day
4 SET thirty_days_ago = temp
5 :loop
6 GETNEXTFILE "*" /oldest
7 IFERROR RETURN $ERROR_SUCCESS
8 IFDATETIME> %nextfiledatetime thirty_days_ago RETURN $ERROR_SUCCESS
9 ;; File is more than 30 days old, so delete it
10 DELETE %nextfile
11 ;; It's a good idea to make sure the delete doesn't fail due
12 ;; to a permissions issue (want to avoid getting stuck in
13 ;; an infinite loop).
14 IFERROR RETURN
15 GOTO loop