Comparing Local and FTP Site File Dates and Times

Top  Previous  Next

 

Robo-FTP provides a set of commands permitting the date/time stamps of local and FTP site files to be compared against specified date and time strings or variables.

 

If you wish to compare a file date/time stamp against specified dates or times rather than against another file, the IFDATE and IFTIME script commands may be used. When used this way, the complete script command is formed by adding one of the following comparison operators:

 

>=Greater than or equal to (e.g., IFDATE>= or IFTIME>=)
<=Less than or equal to (e.g., IFDATE<= or IFTIME<=)
=Equal to (e.g., IFDATE= or IFTIME=)
>Greater than (e.g., IFDATE> or IFTIME>)
<Less than (e.g., IFDATE<  or IFTIME<)
!=Not equal to (e.g., IFDATE!= or IFTIME!=)

 

The IFDATExx and IFTIMExx commands always compare the specified date or time against the date/time stamp of the most recent file obtained with the GETNEXTFILE or GETSITEFILE script commands.

 

The following example branches if the date of a local file obtained with GETNEXTFILE is found to be later than January 1, 2003.

 

GETNEXTFILE "*.*"

IFDATE> "01-01-03" goto new_file

 

The date variable or string must be in the format of mm-dd-yy or mm/dd/yy. (Note: Robo-FTP always uses the former format internally so that the date variable may be used in the creation of file names.) The time string must be in the format of hh.mm.ss, hh:mm:ss, hh.mm, or hh:mm. When times are compared, seconds are always ignored.

 

The following example branches if a time of an FTP site file obtained with GETSITEFILE shows that it was created after 1PM.

 

GETSITEFILE "*.*"

IFTIME>= "13:00" goto new_file

 

Important

The IFDATE and IFTIME commands always operate against date and time values saved from the most recent GETNEXTFILE or GETSITEFILE script command. In other words, insofar as these IFDATE and IFTIME commands are concerned, GETNEXTFILE overwrites the saved date/time values from a previous GETSITEFILE, and vice versa.

 

Important

If a given FTP site is hosted on a Unix system and the server file was last written to six (6) or more months prior to the current date, the comparison is based on the stored month, day, and year - but the server file time is assumed to be 12:00 AM (since the actual time is not available to Robo-FTP for comparison purposes).

 

See Timezone Differences for information on how to account for timezone differences between where Robo-FTP is located and where the server is located or if the server defaults to GMT when updating file date/time stamps.