Skip to main content

TrFile_GetExtension (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetExtension
Troi File Plug-in for FileMaker Pro

TrFile_GetExtension

Returns the extension of a file path

SyntaxFunction badge

TrFile_GetExtension ( switches ; filePath )

Parameters

switches not used, reserved for future use. Leave blank or put "-Unused"
filePath the path to the file of which you want the extension

Returned Result

Data type returned

Text

Result

the extension, which is the part of a filename in the file path after the last period.

If the file name in the path does not have an extension “” is returned.

Originated in

Troi File Plug-in 12.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

You can use this function to easily determine the extension of a path (or filename).
If the file name in the path does not have an extension “” is returned.
Note that the plug-in checks if the last period is not in a subfolder of the path, so on macOS “MacHD:data.kip:filename” will not return “.kip:filename” as the extension but “” as expected.
And on Windows “C:\\Users\data.kip\filename” will not return “.kip\filename” as the extension but “”.
The function also works with (fully qualified) FileMaker Pro paths which use forward slashes.
The plug-in does not test if the path is correct or if the file exists.

Example

TrFile_GetExtension ( "" ;  "C:\Test.txt" ) ]

This will return the extension “txt”.

TrFile_GetExtension ( "" ;  "MacHD:data.kip:filename" ) ]

This will return the extension “”.

TrFile_GetExtension ( "" ;  "/MacHD/trident/submar/filename.log" ) ]

This will return the extension “log”.

Example 2

Set Variable [ $Extension ; TrFile_GetExtension ( "" ; "filemac:/Mac HD/Users/Smith/report.fmp12" ) ]

This will set the variable $Extension to “fmp12”.

Used in example file

Attribute.fmp12

Related functionsFunction badge

TrFile_Exists
TrFile_GetFileName
TrFile_GetTypeOfItem

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_GetExtension (filep4323) 2024-0604 19:50:30