Batch removal of unwanted tags

Stupid me. I spent hours creating an elaborate tag system, and now I want to get rid of it. Would like to be able to select several dozen tags and remove them from all drafts. Is this possible? If so, how?

You cannot select multiple tags at the same time, there is a “Delete Tag” command in the contextual menu of tags in the tag filter list, however, to do it one-by-one.

depending on the amount of tags it might make sense to create a script for that to delete them.

if you remove a tag from all drafts that have it, the tag will also be deleted AFAIK.

simple enough script would be :

badTags = ['tag1','tag2 ','tag3'] // lower case   
for (b of badTags) {
let dArr = Draft.query("", "all", [b]) 
    // assembles all drafts with that tag,     
    // regardless of content or location
alert(dArr.length + " drafts found tagged with '" + badTag + "', will delete that tag from all.")
 // if desired, delete the alert line (it is unnecessary, info only)

for (d of dArr) {
   d.removeTag(badTag);
   d.update();
   } // end of d of dArr loop

} // end of b of bTags loop

This strips the tags from all drafts, though I think the bad Tag still will still show in the recent tags list for the immediate future, but it will drop aside eventually.

1 Like