Tags... (Edit Tags of Selected Finder Items)

I was reluctant to share this one, because its purpose is relatively simple, but I learned a few things making it that I thought were worth sharing.

You know how Finder has a menu item "Tags..." under the File menu, but you can't assign it a keyboard shortcut? As far as I know, if you want to see this tag editor:

Screen Shot 2022-02-07 at 11.15.34 PM

... you can click the menu item, click the Edit Tags/Add Tags button on the Finder menu bar, or right click the file/folder(s) to get to the context menu. click click click

This macro reveals that "pop over" menu

It does so by (ahem) clicking the Edit Tags/Add Tags button for you - if it exists. This is a UI scripting thing, but I tried to make it somewhat forgiving as far as the name of the button and its location on your menu bar. The single button, which must be on the Finder menu bar, will be called either "Add Tags" if the Finder selection has no tags, or "Edit Tags" if the Finder selection already has tags to edit or if nothing is selected.

If nothing is selected, the macro cancels with a notification. Otherwise, the macro tries to find the button.

If an item is selected, but the button is not visible due to the size of the Finder window, the window will be maximized to (hopefully) reveal it. The original size and location of the window is stored and then restored once the Tags pop over is closed, which I thought was a handy feature (shown in blue).

Given that this relies on scripting the Edit Tags/Add Tags button, which will be in a different spot depending your configuration, it's possible this won't work out of the box for you. But if it does, or if there's a better way to get to that darn pop over without a mouse, I'd love hear about it :slight_smile:

Tags....kmmacros (14 KB)

Macro Screenshot

1 Like

Hello @evanfuchs, here are my macros for capturing tags. These work in the Finder window, as well as on the desktop.

2022_02_08_Support_1

Finder tags are entered via a KM input window:

07)Add <7A4C 220208T203616>.kmmacros (39,8 KB)

Click to show image

07)Add <7A4C 220208T203616>

2

The file info window is displayed in the center of the screen (here 27 inches) and the tag input window is activated for input:

05)Info <B074 220208T203635>.kmmacros (33,4 KB)

Click to show image

05)Info <B074 220208T203635>

1 Like

Hey, thanks @appleianer. I do have various macros for setting and clearing tabs, but yours look much more robust. I will definitely check them out :+1:

For this exercise, I was specifically looking to see if I could get that elusive pop up to work without a mouse!

1 Like

Nice. You can also reveal that tag editor UI thusly:

image

Hey there.

That way isnā€™t reliable for me. I think it may work sometimes depending on certain setups, but whatever that setup is, isnā€™t persistent.

For example, although I see Tagsā€¦ listed under the Finder File Menu, I cannot access it by typing ā€œTagsā€¦ā€ with the File Menu open like I can most sub menu items, and that Select Menu action error running that action gives me this error:

image

ACTION ERROR:	Fileāž¤Tags.... 

Select Menu Item failed to find target menu item Fileāž¤Tags.... Macro ā€œShow Tags Menuā€ cancelled (while executing Select ā€œTags...ā€ in the Menu ā€œFileā€ in Finder

There is something about that particular menu item that behaves differently (read: badly).

That's strange. If you could post your macro with the faulty menu select function, I'd love to see if it works for me.

Here's mine:

DISPLAY OR EDIT TAGS.kmmacros (33.5 KB)

Your macro produces the same error for me. It's not Keyboard Maestro, it's a Finder.

In some cases, the "Tags..." menu item may not respond to the keyboard like most menu items. For example, if you press āŒ˜? in Finder and type the name a menu item into the search box, that menu item will usually show up in the results. Not always true for "Tags...":

  • In Finder preferences, under the Tags tab, try removing all tags from the "Favorite Tags" box.

  • Press āŒ˜? and type "Tags..." - It might show up.

  • Now add a tag to "Favorite Tags" and try it again. It probably does not show up.

@peternlewis may be able to offer more insight into why a particular menu item may not work with the Select or Show a Menu Item action, but it seems to coincide with whether or not that menu item is available to the keyboard in this way.

I remember this bug now and on my end deleting all the favorite tags made this work reliably.

3 Likes

After I deleted favorite tags so as to enable the keyboard shortcut invocation of the tags editing UI, I created an "Add Favorite Tags" macro to sort of recreate that option. It allows you to select from a list of favorite tags which you can edit within the "Prompt with list" action. It then asks if you want to add any other tags which you can manually input; then it sets the tags to the finder item. The macro does not utilize the UI editor or the Info window, but rather the KM "Set Tags" action.

ADD FAVORITE TAGS TO FINDER ITEM.kmmacros (26.6 KB)

1 Like

The Finder Tags menu item is ā€¦ weird. Pretty much always has been.

If you look at it with the UI Inspector, you can see it is quite different from other menu items:

The most clearly problematic part is it has no AXTitle.

If you turn on VoiceOver and hover over the menu, interestingly it knows it is Tags, but adds the word ā€œinteractiveā€ after it.

Another clue is to open the File menu, and then press the ā€œTā€ key and note that it does not select the Tags menu, but instead selects a menu starting with ā€œSā€.

Basically, use the Set File Attribute action to set tags.

3 Likes

Thanks, Peter. The macro I posted above does just that. Because I hate the "Get Info" UI and the tag editor UI, I also created a macro to display a finder item's current tags:

DISPLAY TAGS FOR SELECTED ITEM - v1.1.kmmacros (27.6 KB)

The macro uses an Applescript I cadged from this website and modified for simplicity. There's probably a simpler way to get just the right display text using regex, but I kinda brute forced it.

(UPDATE - Apologies - the previous version of this macro omitted necessary actions which get the POSIX path, in quoted form, of the selected Finder item. I included that step originally in a clause in the Applescript which called a subroutine macro for that purpose.)

image

Result is a dialog displaying tags which disappears in 3 seconds or can be dismissed.

2 Likes

Opening the Tags... menu displays a few tags, but I don't see anything calling them "Favorite Tags". Are these the tags you mean, and wouldn't "removing" them remove them from all files?

Are you looking at Finder Preferences? Press āŒ˜, in Finder to open Preference, and look for the Tags tab.

Hey BK - Thanks for your post on "delete 'favorite tags' to restore function to Finder tags pop-up short-cut"!

It worked perfectly - my previous (system prefs) shortcut (ctrl-space) started working again, after untold months of giving up that functionality.

Steve

2 Likes

Also confirmed at the end of video here:

For those following this thread...

I'm working on a Finder-related macro that includes a feature to set tags. It includes the concept of a Tag Clipboard that can be applied to files and folders. Yes, the tag dialog is butt-ugly, but once you get the hang of it, it's very quick and easy to use:

Note: For the example above, the file 2022-12-14 17.14.20@2x.png was selected when the macro was triggered.

For more information, see: Want to Help Test a Finder-related Macro? - Questions & Suggestions

2 Likes