Name

get eof — get file end position

Description

Returns the 1-based index of the last character of a file (which is also the size of the file).

Because character positions are 1-based, and because the eof is the position of the last character, if you want to append to a file you must start writing at a position one greater than the eof. That is the largest position at which you are permitted to start writing.

Example

write "Howdy" to f
set ourEof to get eof of f
write "Doody" to f starting at ourEof + 1

Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.