TrFile_GetFileAttribute (function reference)

By January 1, 2021January 26th, 2021Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetFileAttribute
Troi File Plug-in for FileMaker Pro

TrFile_GetFileAttribute

Returns an attribute of the file specified by the filePath.

SyntaxFunction badge

TrFile_GetFileAttribute ( switches ; filePath )

Parameters

switches this determines the attribute that is returned
filePath the path to the file

Switches

switches can be one of the following:

-LockAttr return number indicating whether the file is locked (Mac) or Read-only (Windows)
-HiddenAttr return number indicating whether the file is hidden (invisible)
-ArchiveAttr return number indicating whether the file’s archive bit is set (Windows only)
-LabelNumAttr return number indicating the label of a file (macOS only)
-FindercommentAttr return the finder comment of a file (macOS only)
-PackageFolderAttr return number indicating whether the file is a package folder (macOS only)

Returned Result

Data type returned

Text

Result

The returned result is the requested attribute of the file.

Result for switch “-LockAttr”:
Returns 1 for a locked file and 0 for an unlocked file. On Windows it returns the equivalent “Read-only”-attribute: 1 if the file is a Read-only file and 0 otherwise.

Result for switch “-HiddenAttr”:
Returns 1 if the file is hidden and 0 otherwise.

Result for switch “-ArchiveAttr”:
Returns 1 if the file’s archive bit is set and 0 otherwise. This bit is only available on Windows. On macOS this switch always returns 0.

Result for switch “-LabelNumAttr”:
Returns a number between 0 (=no label) and 7. This attribute is only available on macOS. On Windows this switch always returns 0.

Result for switch “-FindercommentAttr”:
Returns the finder comment, which is visible with the Get Info command in the macOS Finder. On Windows this switch always returns “”.

Result for switch “-PackageFolderAttr”:
Returns 1 if the item is a package folder and 0 otherwise. For example all macOS applications are package folders. This attribute is only available on macOS. On Windows this switch always returns 0.

Note that also an error code might be returned. An error always starts with 2 dollars, followed by the error code. Returned error codes can be:

$$-43 fnfErr File not found, check if the path is valid
$$-1 genericErr The file could not be found (older versions of the plug-in)

Other errors may be returned.

Originated in

Troi File Plug-in 2.0

Compatibility

FileMaker Pro 16 to 19

Considerations

The switch “-PackageFolderAttr” can be used to determine if a result of the drag and drop action is a package.
You can use FileMaker styled paths, like “filewin:/C:/MyFiles/test.txt”.

Example

Set Field [ result ; TrFile_GetFileAttribute ( "-LockAttr" ; "C:\test.doc" ) ]

The result will be 1 if the file is Read-Only and 0 otherwise.

Example 2

We assume that in your FileMaker file the following fields are defined:

    locked		text
    filePath		text

“filePath” should contain the path to an existing file, for example “D:\Out.txt” (Windows) or “Mac HD:Out.txt” (Mac). In a script add the following script step:

Set Field [ locked ; TrFile_GetFileAttribute ( "-LockAttr" ; filePath ) ]

This will get the locked status (1 or 0) of the file into the field “locked”.

Used in example file

Attribute.fmp12

Related functionsFunction badge

TrFile_DragAndDrop
TrFile_IsFree
TrFile_SetFileAttribute

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 16 to 19 –> TrFile_GetFileAttribute (filep4234) 2021-0125 21:36:05