Table of Contents

Get File Attribute Action

The Get File Attribute action returns the specified attribute for the specified file to a Variable.

How To Use

Click the File Chooser button to the right of the action to select an existing file on disk. Option-click on the File Chooser button to show the currently selected file in the Finder (assuming it exists already).

The result of the action is displayed at the bottom of the action.

File attributes available

  • file type (Directory, Package, File, Symlink, Socket, Character Special, Block Special, or Unknown).
  • file size in bytes.
  • creation date.
  • modification date.
  • added date.
  • last used date.
  • downloaded date.
  • where from.
  • owner name.
  • owner id.
  • group name.
  • group id.
  • POSIX permissions.
  • extension hidden.
  • invisible.
  • HFS creator code.
  • HFS type code.
  • content type.
  • content kind.
  • tags.
  • comment.
  • parent path.
  • file name.
  • base name.
  • extension.
  • display name (v9.0+).

Note that content type, content kind, added date, downloaded date, where from and comment are all part of Spotlight and will not work if the directory or volume is excluded from Spotlight.

Addition File Attributes

There are several more attributes available using the Filter action.

If you select an Alias or SymLink file using the File Chooser it will return the target rather than the actual path.

If you want to determine if the Finder Item is an Alias or SymLink, you can use this AppleScript, which will return either “Link: Alias” OR “Link: SymLink” OR the file kind.

snippet.applescript
tell application "Finder"
  set theSel to the selection
  set theItem to item 1 of theSel
  set itemKindStr to (kind of theItem) as text
 
  if (itemKindStr ≠ "folder") then
    set itemFileType to (file type of theItem) as text
  else
    set itemFileType to "folder"
  end if
 
  if (itemKindStr = "Alias") then
    if (itemFileType = "missing value") then
      set itemKindStr to "Link: SymLink"
    else
      set itemKindStr to "Link: Alias"
    end if
  end if
 
end tell
 
return itemKindStr
-->Link: Alias
-->Link: SymLink
-->BBEdit text document

See Also

Actions

Conditions

Forum