Set Finder Label


#1

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)


#2

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.


#3

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


#4

The label you can get via AppleScript:

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

#5

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.


#6

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


#7

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


#8

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.


#9
  • 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.


#10

Some days ago, but thanks for this Tom.


#11

Thanks for this Peter.