The filesize( function determines the size of any file on disk.


This function has one parameter:

path – is a path to the file, including the file name (see Files and Folders for more information about file paths).


This function returns the size of the specified file (in bytes). This example calculates the size of a file named news.txt in the Documents folder.


This example checks to see if a file is empty, and if so, deletes it.

local theFile="~/Documents/updates.txt"
if filesize(theFile) = 0
    fileerase theFile

Note: If the file contains text, the number returned may not be equal to the number of characters in the text. Different text encoding systems may use two or more bytes to store a single character. The only reliable way to determine the number of characters is to use the fileload( function to load the text into a field or variable, then use the length( function to count the characters.

Advanced Tip: Very old (pre OS X) files can contain resource forks as well as data forks. This function only returns the size of the data fork, not the resource fork.

Legacy Syntax (Separate Folder and File Parameters)

In older versions of Panorama (6.0 and earlier) the filesize( had two parameters, folderid and filename. To maintain compatibility with older databases, two parameters will still work, as shown in this example:


For new databases you’ll probably find it easier to use the single parameter mode.

See Also


10.0UpdatedCarried over from Panorama 6.0, but now may have either one parameter (path) or two (folder, path).