Deleting all Finder tags with character length = 36 characters - HowTo?

Hi folks,
Please bear with me, as I have little automation experience, but am not afraid and willing to learn. I am comfortable working in terminal, so no issues there.

My problem is as follows:
I’m quite a heavy user of DEVONthink. Now one way or the other I have been bitten by this issue in the past. It took me a long time to solve it, and unfortunately I forgot all about it. Untill this past week…

DEVONthink can write “tags” to Finder-tags.
Now I have somehow collected an enormous amount of tags in some way our of my own free will. Not entirely sure, but I thinks these tags were automatically added due to an enabled setting (probably default, but not sure) to convert categories and hashtags to tags

After some time, these tags start piling up, and my mac got slow and sluggish and came to a near grinding halt.

At some point I also started to get a view a lot of messages in the Activity Monitor that were all related to OpenAndSavePanel

So today, I’m looking at ways to use a script to delete all Finder tags that have a length = 36 characters.

I’d be very happy to get help and would appreciate any pointer in the right direction.

disclaimer: In no way this post is meant to be negative about DEVONthink or their software or help forums. They have and continue to be very helpfull, but I think that solving this issue is more of a mac’s issue that I would like to learn and try to solve using scripting.

Thanks for any help or pointer!

Depending your own tags that you’d want to keep, there’s two one-shot solutions (that are actually not automation)

  • If you don’t use tags at all: In your Finder Preferences window click on any tag in the list then hit Cmd+A, then click on the minus sign and confirm. This will take a LONG time.

  • If you do want to keep some tags: In your Finder Preferences window click on any tag in the list then hit Cmd+A. Then, carefully Command+click on each tag you want to keep to unselect them. Then click on the minus sign and confirm. This will take a LONG time.

Do look for the preference that does this in DEVONthink and disable it, because this is insane!

And @ipanini welcome to the forums, by the way :slight_smile:

Thanks sebastienkb!
I have indeed lost a great part of the day in doing this manually.
Have just succeeded in installing xcode + cmd line tools on my (still) Catalina macOS system.
Also installed Homebrew.
Will proceed in trying github’s jdberry/Tag and see if I can get it to work. My main question then is how to “select” tags with character length = 36…

Hope to see more suggestions come through, and will keep the forum informed about my proceedings.

I was actually going to suggest the Tag tool afterwards (according to what Google outputs as answers anyway) but I always like try to have a solution without forcing new tools if maybe an alternative exists.

But now that we didn’t make it with just Finder, let’s go down that rabbit hole :rabbit2: put on your nerd glasses and read along.

I hacked around with tag and ended up with this: Please create a file called on your Desktop and put this inside it (this is a bash script, feel free to ask questions if you want to know more about a line):


tag --usage | cut -w -f2 | while read aTag ; do
    if [[ ${aTag//-/} =~ ^[[:xdigit:]]{32}$ ]] ; then
        echo "🚨  Found a tag to delete: $aTag"
    	tag --find $aTag | while read aFileWithThisTag ; do
    		tag --remove "$aTag" "$aFileWithThisTag"
    		echo "✅  Tag deleted from $aFileWithThisTag"
    	echo ""

Note: I’m assuming that your tags are actually UUIDs, i.e. formatted unique codes. Checking for 36 characters would have worked, but I happened to have dealt with UUIDs recently so it’s fresh in my memory.

When saved, open Terminal and run this:

sh ~/Desktop/

How it works:

  1. First it finds all existing tags on your system
  2. Then it finds all files related to each tag
  3. Then it deletes the tag from each of those files

Okay that’s fun and all but we’re not done yet and I didn’t find a solution for what follows.
Even though the tags are gone from the files, they still exist as available entries for Finder !

Your core issue is that your mac became slower due to tags. Is the removal of tags from files sufficient to relieve your Mac, or do we need to clear that list too? I don’t know and documentation about that is yanky at best.

There are topics saying that deleting ~/Library/Application Support/ would help (+ restart Finder, + restart Mac), but it doesn’t on macOS Monterey. Maybe it would work on Catalina?

The tag command can deal with tags on files, but not tags that are available in Finder’s preferences.

Have fun!

I believe that when a Finder tag is deleted, it is removed from any files that made use of it. Therefore it’s probably not worth the extra expenditure of retrieving files with these tags and operating on them; just delete the tags.

1 Like

True, but I felt that the manual deletion of tags in the Finder window was a problem in the first place. Just making assumptions though.