Skip to main content

TrFile_GetTypeOfItem (function reference)

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

TrFile_GetTypeOfItem

Returns the type of an item, for example if it is a folder or a file.

SyntaxFunction badge

TrFile_GetTypeOfItem ( switches ; filePath )

Parameters

switches modifies the behavior of the function
filePath the path to the file or folder for which you want to know the type

Switches

Switches can be empty or you can add this switch:

-AddAliasInfo if it is an alias file (or shortcut on Windows) the result will be "file (alias)".

Returned Result

Data type returned

Text

Result

The returned result can be one of:
– file: if the path points to a file
– folder: if the path points to a folder (directory)
– package folder: if the path points to a package folder (Mac OS only)

If the path does not exist or if an error occurs an error code will be returned, starting with $$. Returned error codes can be:

$$-43 fnfErr File or folder not found
$$-50 paramErr Parameter error

Originated in

Troi File Plug-in 5.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

This function provides an easy way to see if a path points to a folder or a file. Please note that in the future other types may be returned.

About package folders: these are folders that behave more like a file. For example all macOS applications are package folders.

Example

TrFile_GetTypeOfItem ( "-Unused" ;  "C:\Test.txt" )

This will return “file” if the file exists (and is a file). If it does not exists $$-43 is returned.

Example 2

Set Variable [ $whatKind ; TrFile_GetTypeOfItem ( "-Unused" ;  "filemac:/Mac HD/Users/Smith/Data Folder ) ]

This will set the variable $whatKind to “folder” if the folder exists (and is a folder). If it does not exists $$-43 is returned.

Used in example file

Attribute.fmp12

Related functionsFunction badge

TrFile_Exists
TrFile_GetExtension
TrFile_GetFileKind
TrFile_ListFolder

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_GetTypeOfItem (filep4300) 2024-0604 19:21:24