Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Files.FileSize

Queries file size.

Component Version macOS Windows Linux Server iOS SDK
Files 2.7 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Files.FileSize"; Path { ; Options } )   More

Parameters

Parameter Description Example Flags
Path Native path to the file to check. "C:\test\me.jpg"
Options Optionally specifies on macOS what size is returned.
Default is total logical file size. Pass datafork or resourcefork to limit query to only size of given fork. And pass physical or logical to query logical size or the physical size, defined by blocks used on Disk.

Pass combination of total, physical, datafork, logical, resourcefork.
"physical datafork" Optional

Result

Returns file size in bytes.

Description

Queries file size.
This function needs a native path. Please use Path.FileMakerPathToNativePath function in order to convert a FileMaker style path to a native path.
With 2.9 plugins you can set parameter to query only size of resource fork or data fork on macOS. And you can define if you want to query size on disk (rounded up to block size) or the logical size.

Examples

Queries file size of a file

MBS( "Files.FileSize"; "C:\test.txt" )

Queries logical data fork size of a file on macOS:

MBS( "Files.FileSize"; "/Users/Shared/Test.txt"; "datafork" )

Queries physical size of a file on macOS:

MBS( "Files.FileSize"; "/Users/Shared/Test.txt"; "physical" )

Queries physical resource fork size of a file on macOS:

MBS( "Files.FileSize"; "/Users/Shared/Test.txt"; "physical-resourcefork" )

Queries physical data fork size of a file on macOS:

MBS( "Files.FileSize"; "/Users/Shared/Test.txt"; "physical datafork" )

Query all file names and sizes for files on desktop:

While(
[
    names = "";
    // query list of visible files on desktop
    folder = MBS("Folders.UserDesktop");
    list = MBS( "Files.List"; folder; 1+4 );
    count = ValueCount(list);
    index = 1
] ;
    index ≤ count ;
[
    filename = GetValue(list; index);
    filepath = MBS("Path.AddPathComponent"; folder; filename);
    // query size for each file
    size = MBS( "Files.FileSize"; filepath);
    names = names & filename & " -> " & size & ¶;
    index = index + 1
] ;
// return all the names
names )

Example result:
test.zip -> 834
test.rtf -> 400

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 14th June 2022


Files.FileNameWithoutExtension - Files.FileUTITypes