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.
date_in_filename.s
Robo-FTP's built-in %date variable is handy for downloading files where the filename contains today's date. This sample script shows how you can use it together with the DATAESUB command to download files named with yesterday's date. It also shows how to use the SETEXTRACT command to parse the date so you can rearrange the order from mm-dd-yy to yyyy-mm-dd.
1 WORKINGDIR "c:\download\destination\folder"
2
3 ;; The next two lines will:
4 ;; 1) Get today's date string in mm-dd-yy format
5 ;; 2) Subtract 1 day to get yesterday's date
6 SET yesterday = %date
7 DATESUB yesterday 1
8
9 ;; Parse date as string with "-" character as delimiter
10 ;; then rearrange the values to change the name pattern
11 SETEXTRACT month = yesterday "-" 1
12 SETEXTRACT day = yesterday "-" 2
13 SETEXTRACT year = yesterday "-" 3
14 SET MyWildcard = "*20" + year + "-" + month + "-" + day + "*"
15
16 ;; Download all files that match name wildcard pattern
17 FTPLOGON "ftp.mydomain.com" /user="UserID" /pw="Secret"
18 RCVFILE MyWildcard