Set Finder Label

This plug-in will set the Finder label of a file.

Download this zip file and drop it on Keyboard Maestro to install the Plug In Action:

SetFinderLabel.zip (7.9 KB)

5 Likes

A classic osx irritation for scripting - this really helps! Was scratching my head about plugins in KM, but this example helps me understand.

At that time when label-band became multi-label/tag-dots, we lost the old label-set system. But is there a way to return the value of the current Finder Label/Tag (first, or multiple array, i guess) into a variable like finder_tag_colour ??

Such a converse plugin also interesting to me.

The Get File Attribute action can get tags, and the Set File Attribute action can set, add, remove, or toggle tags.

The label you can get via AppleScript:

tell application "Finder"
  get label index of alias "<HFS file path>"
end tell
1 Like

Peter, yet another treasure chest of functionality - I had no idea those were there. :grinning: So then a question, and a remark:

  1. tags (remove) nukes all tags or do you need to explicitly specify?

  2. I’ve defected from Finder to Path Finder; I just noticed (THANK YOU!) that in PF the colour tags are available as attributes/selectable menu items. There’s also a menu item for ‘copy path/HFS’ for highlighted, so it appears I can use KM to add various additional functionality to PF. Amazing.

Thank you, Tom. Do we expect to be able to ‘tell application “Path Finder”’ the same thing?

I have no idea. But, since Finder is running all the time, it doesn’t harm to ask the Finder for the label information. (It will not bring the Finder to the foreground, or something like that.)

PS: You can look it up in Path Finder’s AppleScript dictionary:

Open Script Editor, File > Open Dictionary…, double-click Path Finder in the list.

In the dictionary window, make sure “AppleScript” is set as language. Type “label” into the search field.

  • set tags - removes all tags and sets the specified ones
  • remove tags - removes the specified tags, leaving any others remaining
  • add tags - adds the specified tags
  • toggle tags - each specified tag is added if it is not already present, or removed if it is.

In all cases, you can't have duplicate tags, so adding a tag a second time has no effect.

1 Like

Some days ago, but thanks for this Tom.

Thanks for this Peter.