I have imported old emails from Outlook backups in my Gmail account and I ended up with 1000+ labels in my system. Is there an easy massive way to remove them and keep only ~10 my usual ones?
-
You can do only one-by-one as GMail doesn't offer bulk operations with labels.– dnbrvApr 9, 2012 at 17:46
-
ANSWER HERE: webapps.stackexchange.com/a/129064/186471– user0Apr 27, 2019 at 12:55
-
1i.stack.imgur.com/yaGB1.png– user0Apr 29, 2019 at 11:55
-
1@user0 I shouldn't have jumped into conclusions :) my apologies.– Chris-TopApr 29, 2019 at 12:47
8 Answers
I wrote a script to add to Google Scripts.
function removeLabel() {
var labels = [];
labels = GmailApp.getUserLabels();
//Loop through all Labels
for (var i = 0; i < labels.length; i++) {
if (labels[i].getName().indexOf("WORD TO FIND IN LABEL NAME") > -1) {
//If the WORD is found in label name - delete the label
labels[i].deleteLabel();
}
}
}
-
-
Just a quick question: exactly what does this do? I'm looking for a Google Script to switch On "Show if unread" for all my (1000+) Labels. Sep 14, 2018 at 0:13
-
OK, figured it out, sort of. You have to replace "WORD TO FIND IN LABEL NAME" with yr Label name. Can I use a regex to delete them ALL in one fell swoop? Sep 14, 2018 at 10:04
-
I have looked here: developers.google.com/apps-script/reference/gmail/gmail-label but can't seem to find any way to programmatically access the "Show if unread" function. Sep 14, 2018 at 10:13
-
Worked like a champ. I removed the .index from the condition. In my case I wanted to delete all labels from the users inbox after migration from Office365.– MattNov 16, 2018 at 6:08
Not with stock Gmail. There may be a userscript out there to allow you to do that, but I wasn't able to find one with a cursory search.
Another option might be to use an IMAP client, such as Thunderbird. Thunderbird maps pretty well its folders to Gmail labels. You might be able to bulk delete within Thunderbird and have the labels magically disappear. I admittedly haven't tried it (don't have T-bird in the office) and you should be careful that it doesn't end up deleting messages too.
The Google script posted in other answer (and this one) worked Perfectly.
function removeLabel() {
var labels = [];
labels = GmailApp.getUserLabels();
//Loop through all Labels
for (var i = 0; i < labels.length; i++) {
if (labels[i].getName().indexOf("WORD TO FIND IN LABEL NAME") > -1) {
//If the WORD is found in label name - delete the label
labels[i].deleteLabel();
}
}
}
I used a mouse and keyboard macro to do this. It is not a very smart way, but it does the job quickly.
On macOs I used the following script with KeyboardMaestro:
You would have to create a new macro, press "record" and manually delete one label on the Gmail settings tab.
Then add a "Control Flow" "Until" statement, that's a for loop.
I find this utility of very use.
Not a solution but a way to make your life a lot easier.
AutoHotkey script:
y::
Click
Send +{TAB 2}
SEND {ENTER}
Return
Move your mouse on the first label delete link, press Y and continue for every label you want to remove.
it is possible to remove or hide labels in gmail by changing the view from HTML view to classic view. Go into settings, scroll down to labels. You can then choose which to remove or hide using check boxes. Nested labels are removed on bulk by selecting the top of the tree. Then revert
Actually - there is a way. Labels are attached to contacts, so by replacing your contacts, you can remove labels.
Its a little complicated, but here's how:
Export all your contacts.
In the CSV file, delete the column 'Group Membership" (note, this is a way to get rid of all labels, if you want to get rid of just some, just clear the field in the column Group Membership for all labels you want removed)
Delete all your contacts. Yes, this is scary, but you just exported them all. Make sure to check your export file before you do this, and see if you see your contacts. To delete all your contacts at once, choose the 'more' dropdown under the contacts interface, and restore to a date before you opened your Gmail account.
Now to re-import - Once that column "Group Membership" is removed ( or cleared for the labels you want gone ), re import your contacts. All the labels that do not exist in the CSV will be removed from your Gmail interface!
Cheers!
-
2Labels don't have anything to do with contacts. Labels are applied to messages. Contacts are in Groups.– aleMar 1, 2016 at 18:59