FILECOMPAREFROM Compare remote file to local file
<< Click to Display Table of Contents >> Navigation: Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands > FILECOMPAREFROM Compare remote file to local file |
Syntax: |
FILECOMPAREFROM |
[ file name ] |
Arguments: |
[ file name ] |
|
Options: |
/tz=xx |
Timezone adjustment (in hours) between the local PC and the remote site; value is expressed as a positive or negative integer; used when local and server file’s time/date stamps are compared. This option is functionally equivalent to calling the TIMEZONE command so this adjustment persists after the execution of the current line of script. This option is deprecated in favor of the TIMEZONE command. |
This command compares the size and date/time stamp of a specified file on the remote site with a file of the same name in the current folder on the local PC.
The results of the comparison are saved in two internal script variables: size result is saved in %comparesize and date/time result is saved in %comparedate. These variables may then be tested using the IFSIZE and IFDATE commands respectively. (Do not use the IFERROR command.)
Consider the following example where a file on the FTP site is compared to a correspondingly named local file and a conditional branch is taken if the files are the same size.
FILECOMPAREFROM "server_file"
IFSIZE $ERROR_FILES_SAME_SIZE GOTO save_this_file
If you are not using the TIMEZONE script command, you may specify the /tz option to account for differences in timezones between Robo-FTP and the remote site. This is important for accurate file date and time stamp comparisons. For example, if you are using Robo-FTP in the Central U.S. timezone and the remote site is located in the Eastern U.S. timezone there may be a one-hour difference between the file system times of Robo-FTP’s PC and the FTP site. To allow for this in the FILECOMPAREFROM command, the command would look like the following which indicates that the FTP site is one hour ahead:
FILECOMPAREFROM "server_file" /tz=+1
IFDATE $ERROR_LOCAL_FILE_OLDER GOTO download_file
IFDATE $ERROR_NO_LOCAL_FILE_EXISTS GOTO download_file
Further, if the FTP site is located in the Pacific U.S. timezone there may be a two-hour difference the other way between the file system times of Robo-FTP’s PC and the FTP site. To allow for this, the command would look like the following which indicates that the FTP site is two hours behind:
FILECOMPAREFROM "server_file" /tz=-2
FILECOMPAREFROM populates the value of %comparesize as follows:
$ERROR_FILES_SAME_SIZE |
1234 |
Local and FTP site files identical in size |
$ERROR_LOCAL_FILE_LARGER |
1235 |
Local file is larger |
$ERROR_LOCAL_FILE_SMALLER |
1236 |
Local file is smaller |
$ERROR_NO_LOCAL_FILE_EXISTS |
1239 |
Local file does not exist |
$ERROR_LOCAL_FILE_EMPTY |
1240 |
Local file exists but length equals 0 |
FILECOMPAREFROM populates the value of %comparedate as follows:
$ERROR_LOCAL_FILE_NEWER |
1232 |
Local file is newer |
$ERROR_LOCAL_FILE_OLDER |
1233 |
Local file is older |
$ERROR_NO_LOCAL_FILE_EXISTS |
1239 |
Local file does not exist |
$ERROR_FILES_SAME_DATETIME |
1241 |
Local and FTP site files share same date/time |
Important
The success of this command depends on Robo-FTP's ability to automatically read and understand the directory listings returned by the remote site. Most HTTP/HTTPS sites do not return listings in a supported format and many return no raw directory listings in response to HTTP GET requests based on slash-terminated URLs. Some respond to HEAD requests and are partially compatible. Some supported HTTP listing types like APACHE_DEFAULT include file sizes rounded to the nearest megabyte or kilobyte and are therefore not fully compatible with this command. Contact technical support if you have an urgent need related to a raw directory listing format that is currently unsupported.
Related command(s): IFSIZE, IFDATE, FILECOMPARETO, SYNC, FTPDIFF
See also: Comparing Local and FTP Site Files, FTPGETFILE, SENDFILE, RCVFILE