file.compare

Syntax file.compare (path1, path2)

Params path1 is a legal path name to a file you wish to compare to the file at path2.

path2 is a legal path name to a file you wish to compare to the file at path1.

Action Compares the two files identified by the parameters path1 and path2.

Returns True if the files are equal in every way, false otherwise.

Examples file.compare ("C:\\Program Files\\Frontier\\cactus.gif", "C:\\Program Files\\Frontier\\Copy of cactus.gif")

   » true

f = "System:System Folder:textfile";
file.compare (f,f)

   » true

This script returns true because they're the same file!
Note: comparing a file to itself doesn't yet work on Windows.


file.compare ("System:System Folder:textfile", "System:System Folder:TeachText")

   » false

This script returns false because comparing a document and an application will never produce true.

Errors If either path1 or path2 is a folder, an error results.

Notes The files are equal if they are the same size and if every byte in both the data and resource forks of the two files matches.

Discuss