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

Files.IdentifyData

Checks file type from the data.

Component Version macOS Windows Linux Server iOS SDK
Files 14.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Files.IdentifyData"; FilePath )   More

Parameters

Parameter Description Example
FilePath The native file path.
Something like "/Users/cs/desktop/test.txt" on Mac and "C:\Programs\Data\test.txt" on Windows. Files without path end in the root directory on Mac.
"test.txt"

Result

Returns text or error.

Description

Checks file type from the data.
We read the first bytes of the file and decide which file type is may be.

Supported types:

PDFPDF document.
JPEGJPEG image.
GIFGIF image.
BMPWindows BMP image
WEBPWebP image.
PNGPNG image.
TIFFTIFF image.
GIFGIF image.
SVGSVG image.
ZIPZIP file.
HEIFHEIF image file.
FMPFileMaker database.
EXEWindows executable
MachOmacOS executable
ELFLinux executable

Returns empty text in case the format is not identified. We can add more formats as needed.
Please be aware, that a text file may just have the right bytes to look like another file format!

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Check file type:

Set Variable [$type; Value: MBS( "Files.IdentifyData"; "/Users/cs/Desktop/test.fmp12" ) ]

See also

Release notes

Blog Entries

This function is free to use.

Created 23th December 2023, last changed 8th January 2024


Files.GetTagNames - Files.IsApplication

💬 Ask a question or report a problem