14

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?

6

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();
        }
    }
}
  • It's working like a charm ! – chepseskaf May 14 '18 at 13:53
  • 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. – Michael Beijer Sep 14 '18 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? – Michael Beijer Sep 14 '18 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. – Michael Beijer Sep 14 '18 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. – Mathew A. Nov 16 '18 at 6:08
2

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.

0

Not a solution but a way to make your life a lot easier.

Hotkey 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.

0

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();
        }
    }
}
0

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:

Keyboard Maestro flow

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.

-2
  • Click remove
  • Press Shift + Tab
  • Press Space
-2

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

  • Tried this, but there are no check boxes. – Michael Beijer Sep 14 '18 at 10:05
-4

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:

  1. Export all your contacts.

  2. 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)

  3. 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.

  4. 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!

  • 2
    Labels don't have anything to do with contacts. Labels are applied to messages. Contacts are in Groups. – ale Mar 1 '16 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.