Crap load of tags

I imported thousands of emails into DEVONthink, and had the options set so that it created tags for All Of The Things. Helpful things like: 1, 2, 3, … 0x031b, added, actions, everyone@everywhere.com, etc.

Any recommendations for a utility that works with tags, allows mass deletions, etc.?

It seems like they have to be deleted in the file system, as they “come back” when I delete them in DEVONthink 3.

Did you already try: Finder, preferences, select ‘tags’ tab, right click the tag you want removed, select ‘delete tag’.

What options? Are you using MailTags – otherwise, how did the emails get tagged? You’ll want to look at the source of the tagging and try to stop it there.

How did you import the mail?

Turn on “exclude groups from tagging” in the databases where you imported the mail.

Select all the garbage tags in DEVONthink, delete them.

And, what @Joost said.

Yes, but there are about 38,000 tags.

Edit: 2057 unique tags, 38K tagged files.

Hmm, thats a bunch of right-clicks, got a strong pot of coffee? :smiley: I suggest a two step process, first list all the tags on your system then delete the ones you don’t want with the ‘tag’ utility. You’ll be working from the command line and an editor and need to grab the ‘tag’ utility from here: https://github.com/jdberry/tag

You can list all (most) tags with this:

/usr/bin/mdfind -0 "(kMDItemUserTags == '*')" |xargs -0 mdls -name kMDItemUserTags | grep "  .*" | tr -d ",\" " | sort | uniq > mytags

That creates a text file ‘mytags’ which you can edit with any plain text editor (I use bbedit). If you just want to print a list to the terminal, remove the “> mytags” from the command line above. I take it you don’t want all your tags removed so you will need to use the editor to remove all lines with tags you like to keep.

Sadly, ‘tag’ does not accept input redirection (you can’t do tag < mytags), so you must convert the ‘mytag’ file into a script file by a) pasting "tag -rR " in front of each tag in your text file and “.” right after. E.g., if you had a tag called ABC, your line would need to look like this:

tag -rR ABC .

The lower case ‘r’ is for ‘remove’, the uppercase ‘R’ is for recursive. So this will remove the ABC tag for files in your current folder and subfolders.

With all those changes made, you now need to make the ‘mytags’ file executable with:

chmod +x mytags

Then execute with:
./mytags


Note that I am not very familair with the ‘tag’ utility. I have used it a few times before but not for deleting tags. So if you feel comfortable going this route, perhaps try it out with a single tag first, manually, and build up your confidence with this.

Good luck and welcome to the wonderful world of (bash) script programming …

Thanks!

I found the tag utility earlier, and have been hacking my way through.
I wound up getting a list of all tags, editing that in TextMate, then using xargs and pipes to delete the unwanted tags. There are problematic tags remaining with commas in their names. I’m trying vitag to see if that will work. tag thinks a comma is a tag separator, and I didn’t found a way to convince it otherwise.

Thanks! My first Linux distro (SLS 1.02 I think) came on 50 5¼" floppies and ran on a mighty 386sx-16 :slight_smile:

How much easier might it be to delete and reimport sans tags?

I’ve never liked using tags, and I try to never have to do it, and I’ve never liked keywording photos. With dramatic recent AI advances that will let Photos or Adobe CC or Google Photos pick out things like ‘black dog and blue door’ I think manual human keywording of photos will fall from away within a couple of years. With any luck so will tags. (Though I know that many still think tags are the bee’s knees.)

Thanks. That still leaves the tags in the file system.
I do like tags. They are a helpful way of organizing across folders.

DEVONthink created the tags based on my settings. Totally my fault. Tags created included keywords, email addresses, etc.

Ah, the “Tags” settings in Preferences > Import are pernicious and users should be warned about them. Like any preference, out of sight / out of mind. I think the tags settings should appear in the Import dialogs, not in Preferences.

1 Like

For others that might have this issue (possibly future me), I had problems deleting tags that contained commas, such as “Johnson, John”. I wound up using Finder to rename these tags to 1, 2, etc. then deleted them using the following:

for p in 1 2 3 4 5 6 7 8 9 10; do tag -0 --find "$p" | xargs -0 -I{} tag --remove "$p" {}; echo $p; done
2 Likes