FILECOMPARETO        Compare local file to remote file

Top  Previous  Next

Syntax:

FILECOMPARETO

[ file name ]

Arguments:

[ file name ]

Variable or string defining a local file or path name; if no path is defined  the current working folder is used.

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 local file with a file of the same name in the current directory on a remote site.

 

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 specified local file is compared to a correspondingly named file on the site and a conditional branch is taken if the file on the remote site is larger than the local file.

 

FILECOMPARETO "local_file"

IFSIZE $ERROR_SRVR_FILE_LARGER 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 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 site. To allow for this in the FILECOMPARETO command, the command would look like the following which indicates that the site is one hour ahead:

 

FILECOMPARETO "localfile" /tz=+1

IFDATE $ERROR_SRVR_FILE_OLDER GOTO upload_file

IFDATE $ERROR_NO_SRVR_FILE_EXISTS GOTO upload_file

 

Further, if the remote 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 site. To allow for this, the command would look like the following which indicates that the remote site is two hours behind:

 

FILECOMPARETO "localfile" /tz=-2

IFDATE $ERROR_SRVR_FILE_NEWER GOTO do_download

 

FILECOMPARETO populates the value of %comparesize as follows:

$ERROR_SRVR_FILE_LARGER

1226

File on server is larger

$ERROR_SRVR_FILE_SMALLER

1226

File on server is smaller

$ERROR_NO_SRVR_FILE_EXISTS

1228

File does not exist on server

$ERROR_SRVR_FILE_EMPTY

1229

File exists on server but its length is 0

$ERROR_FILES_SAME_SIZE

1234

Local and FTP site files identical in size

 

FILECOMPARETO populates the value of %comparedate as follows:

$ERROR_SRVR_FILE_NEWER

1221

File on server is newer

$ERROR_SRVR_FILE_OLDER

1222

File on server is older

$ERROR_NO_SRVR_FILE_EXISTS

1228

File does not exist on server

$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 servers 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, FILECOMPAREFROM, SYNC, FTPDIFF

See also: Comparing Local and FTP Site Files, GETFILE, SENDFILE, RCVFILE