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 |
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
- Files.FileInfo
- Files.FileKind
- Files.FileName
- Files.FolderSize
- Files.List
- Folders.UserDesktop
- Path.AddPathComponent
- Path.FileMakerPathToNativePath
Release notes
- Version 11.0
- Rewrote Files.FileSize, Files.AccessDate, Files.CreationDate and Files.ModificationDate to use newer APIs on macOS.
- Version 9.4
- Fixed Files.FileSize for iOS.
Example Databases
Blog Entries
- MBS Plugin Advent calendar: 12 - Files
- Recursive Folder Copy Script
- MBS FileMaker Plugin, version 11.0pr6
- MBS FileMaker Plugin, version 9.4pr2
- FileMaker 18 File Script Steps vs. BinaryFile functions
- Comparing Base Elements Plugin to MBS FileMaker Plugin
- Accept file drops in Filemaker with MBS Plugin
- MBS Filemaker Plugin, version 2.9pr3
- MBS Filemaker Plugin 2.7 Release notes
- MBS Filemaker Plugin, version 2.7pr7
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 14th June 2022