Skip to main content

TrFile_GetFileAttribute (function reference)

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)
-iCloudStatus (macOS) return the status of a file on iCloud Drive: "not on iCloud", "on iCloud + local", "on iCloud only" or "on iCloud (updating)"

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 FileMaker Pro 2023

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”.

v13.0 added the -iCloudStatus switch. The return values for iCloud Status can be:

not on iCloud:	this file is not on iCloud (Drive), it is outside the iCloud Drive (a local file on the disk).
on iCloud + local:	 the file is both on iCloud and on the local disk.
on iCloud only:	the file is only on iCloud, it is not downloaded on the local disk.
on iCloud (updating):	 the file is on iCloud and on the local disk, but it is stale. A new copy is downloading to the local disk.

NOTE If a file path does not exists, other errors like error $$-43 (fnfErr; File not found) or $$-120 (dirNFErr; directory not found) may be returned.

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 2023 –> TrFile_GetFileAttribute (filep4234) 2023-0601 15:26:50