Removing unwanted Tags

Using OSX 10.14.6

I have a lot of unwanted file tags. Frankly, would be happy to get rid of them all and start again. I think so many originated with “wouldn’t it be a good idea” using Mailtags (never did use the numerous tags!). I’ve since uninstalled Mailtags (my email demands much less now), but I’m stuck with a large number of tags. The impact is that when I want to assign a “good” tag, the machine crawls along loading the “lookup list” of tags to re-use if already there. At this point, I want to just delete all and start fresh. finding that impossible so far.

I have found where it shows how to use Finder Menu, Preferences, Tab: Tags, and then select then delete. That doesn’t work. Maybe it works for few but seems to stop working after a while (memory leak?). When select some, press “-” or right-mouse click to delete, nothing happens. When I select one, press “-”, or right-mouse click, nothing happens. I suspect a bug in Finder.

I have found here a terrific thread Crap load of tags using the program “tags” available on Github. That program seems to only delete tags where used on files. If the tag is not in use, it won’t delete it.

Is there some reliable way to get rid of ALL tags? I’m happy to nuke some file which holds the list, but that eludes me (lots of Googling and looking here).

This would be nice to know. I have a lot of tags created by Bookends and DEVONthink that I don’t want.
I just right-click deleted ~25 tags in Finder from the Tags | All Tags… list and didn’t have any problem. But one at a time will take forever. As you’ve said, xattr doesn’t delete them from the system-wide list, only from files.

Another thing that gets in the way is that tags with “funny” characters (how they got there is anybody’s guess), e.g.

1843***650 or "VMwarae Technical Support\

will not delete at all, even if done individually. If included in a big selection, the who selection fails. Maybe be contributing to my problem. So I’m trying to select and avoid those; but i want those funny ones gone too.

Seems like I ran into this and wound up renaming them and then deleting them.

Tried that inside Finder. I now notice you mentioned this at Crap load of tags and gave a script for deleting the renamed files. I’m finding first step to rename doesn’t work. Doesn’t tell me what it doesn’t like. Just does nothing. If I put those funny ones on the sidebar, the delete command works to remove from side bar, but despite premature declaration of success, not removed in the tag list.

Journey continues.

1 Like

Might be coincidence, but seems if the “funny” characters in a tag are “commands” used in Regular Expressions … things go wrong. I don’t see a way around it yet.

I was trying to figure this out the other day and the closest thing I could figure out was using the remove tag feature on Hazel with the specific tags you want deleted.

My hunch is that you are doing this to remove tags that are assigned to files? I can see how that would work; however a bit manual for hundreds of tag and files spread over the file system. FYI, process Crap load of tags might be easier for lots of tags.

I’m at the point where I want to remove tags that are NOT assigned to files but still show up in the tag list. Able to do this manually with the Finder Menu: Preferences, Tab: Tags EXCEPT when the tag holds certain “funny” characters (which I suspect are related to Regular Expression codes).

I have used the technique described to delete tags via the Finder and have found it works properly.

However, the time it takes to completely remove a given tag depends on how many files actually have that tag. You can determine this by (left) clicking on a given tag and Finder will show you all of the files with that tag. I found that for some tags, it actually took quite a while before the tag was fully removed.

This actually makes sense. A given file’s tags are stored in its extended attributes metadata. To remove a tag from the system, Finder must first find all of the files with that tag (this is fast because this information is also stored by Spotlight). Then, Finder has to remove that tag from each of those files one at a time. That can take a while, after which the tag listing in Finder will update to show that tag is no longer present.

I did at one point find a preferences file that contained some, but not all, of the tags I created. I do not know how that file is actually maintained by Finder and how it is used.

At some point, the Spotlight database also has to get updated. I don’t know if there is a call that is made by Finder or by the underlying xattr library to the Spotlight worker processes, or if Spotlight receives an fsevent when metadata is changed, or whether some other mechanism is at play.

You can see all the files on your system that are tagged via:
mdfind 'kMDItemUserTags == "*"'
which will list the full path to every file that has ANY Finder tag attached to it.

If you wanted to have a more visual cued approach to removing tags and your goal is to remove every Finder tag on your system, you could do something like:
mdfind -0 'kMDItemUserTags == "*"' | xargs -0 -n 1 -t xattr -d
which should remove all Finder tags from every file on your system that has a tag and show you the command line for each file as it does the removal.

Please note that I did not test this command on my computer (as I don’t want to delete all of my Finder tags) so use at your own risk.

One additional “gotcha”: If you tag files in a sync’d folder, eg Dropbox or iCloud, it is possible that files tagged elsewhere will propagate back and result in tags reappearing.

1 Like

May I ask how you are trying to remove these “funny” tags?

For all, use Finder Menu: Preferences, Tab: Tags, then right mouse click on the offending tag and attempt to rename. The machine allows me to make the change, then when I save it, the machine ignores the instruction and the tag remains unchanged.

(I suspect these Regular-Express-Like characters are getting in the way. Don’t see yet a way around it. Hope there is a way by-pass the Finder menus, but that is appearing to be unlikely for the time being.)

I think that @nlippman is on to something that it takes time to let the machine go through and remove widely used tags, so I need to be more patient when it is working. But without indication of “working”–some sort of feedback–my impatience was getting in the way. That, plus the failure when working tags with “funny” characters. So current plan:
: grind through and attempt to rename all tags with “funny” characters
: select say 20-50 at a time tags with non-funny charactgers, hit the remove menu, and wait patiently.

Going to take some time. Would be great to have this automated. Heck, that’s what computers are for, but so far I’ve not figured something out.

I think you are on to something. For me, a signal to be patient. I’ll look into your “mdfind” stuff and report back. Thanks!

To clarify, it’s not just removing unwanted tags from files, it is also (to use a different word) deleting those un-wanted and un-used tags from the list of available tags.