Returns an attribute of the file specified by the filePath.
TrFile_GetFileAttribute ( switches ; filePath )
|switches||this determines the attribute that is returned|
|filePath||the path to the file|
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)|
Data type returned
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 Mac OS this switch always returns 0.
Result for switch “-LabelNumAttr”:
Returns a number between 0 (=no label) and 7. This attribute is only available on Mac OS. 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 Mac OS 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 Mac OS X applications are package folders. This attribute is only available on Mac OS. 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.
Troi File Plug-in 2.0
FileMaker Pro 15 to 19
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”.
Set Field [ result ; TrFile_GetFileAttribute ( "-LockAttr" ; "C:\test.doc" ) ]
The result will be 1 if the file is Read-Only and 0 otherwise.
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”.