FILECOMPAREFROM Compare remote file to local file |
Top Previous Next |
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:
FILECOMPAREFROM populates the value of %comparedate as follows:
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. 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 |