User Tools

Site Tools


action:Get_File_Attribute

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
action:Get_File_Attribute [2016/03/10 03:37]
AlainLifchitz add links to actions + forum Google search
action:Get_File_Attribute [2019/03/21 19:15]
JMichaelTX Revise script to distinguish between Alias and SymLink
Line 1: Line 1:
-The Get File Attribute action ​captures ​the specified attribute for the specified file to a Variable. ​+====== 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). 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).
Line 5: Line 9:
 The result of the action is displayed at the bottom of the action. The result of the action is displayed at the bottom of the action.
  
-File attributes available:+===== Using Alias and SymLink Files ===== 
 + 
 +If you select an Alias or SymLink file using the _File Chooser_ it will return the _target_ rather than the actual path. 
 + 
 +{{:​action:​get-file-attribute-km8.png?​nolink|}} 
 + 
 +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. 
 + 
 +```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 
 + 
 +``` 
 + 
 + 
 + 
 +--- 
 + 
 +===== File attributes available ​=====
  
   *file type (r/o).   *file type (r/o).
Line 32: Line 77:
   *base name (r/o).   *base name (r/o).
   *extension (r/o).   *extension (r/o).
 +
 +===== Addition File Attributes =====
 +
 +There are several more attributes available using the [[action:​Filter|Filter]] [[:​Actions|Action]].
 +
 +  * Get or delete the last path component or the path extension.
 +  * Get the basename of the path (ie the name without directory or extension).
 +  * Expand Path to full page, replacing tilde (~) in the path.
 +  * Resolve symlinks, or standardize the path.
 +
  
 ===== See Also ===== ===== See Also =====
Line 40: Line 95:
  
 * [[action:​Set File Attribute|Set File Attribute]] * [[action:​Set File Attribute|Set File Attribute]]
 +* [[action:​Filter|Filter]]
 * [[:​Actions|See all Actions]] * [[:​Actions|See all Actions]]
  
Line 46: Line 102:
 ==== Forum ==== ==== Forum ====
  
-- [[https://www.google.fr/​search?​q=site:​forum.keyboardmaestro.com+Get+File+Attribute|Keyboard Maestro Forum topics about Get File Attribute]]+- [[https://​forum.keyboardmaestro.com/​t/​getting-url-of-most-recently-added-file-to-folder/​2902/​3|Getting url of most recently added file to folder]]
  
 +- [[https://​forum.keyboardmaestro.com/​search?​q=Get%20File%20Attribute|Keyboard Maestro Forum topics about Get File Attribute]]
action/Get_File_Attribute.txt · Last modified: 2023/09/18 04:15 by peternlewis