Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I search for the emails that belong only to a specified label, and do not belong to any other labels.

share|improve this question
unfortunately there is no exclusive flag which really sucks.. specifically i want to find all emails that are in label:web and ONLY in that label... no such way of doing it at the moment besides adding -label:other_label -label:another_label and the list goes on... for the hackers among you - yes, grab a flat list of your labels and write a simple script to generate the command you need... – Nir Pengas Dec 26 '11 at 14:44

You can search for emails that belong to a specific label using the

label:mylabel <include search terms here>

syntax, and you can exclude messages from a specific label using the

-label:mylabel <include search terms here>


So what you want can be accomplished using a combination of these both. You have to compose a search string containing a "-label:mylabel" for all the labels that you have defined, except for the one you are looking for, like this:

label:thisisthelabelimlookingfor -label:label1 -label:label2 ... <include search terms here>
share|improve this answer
yeah i was thinking on the same lines, but thought maybe there is a better way, with much less typing. I have about a 100 labels defined :( – Midhat Feb 21 '11 at 10:57
can i just get a simple plain-text list of all my labels? – Midhat Feb 21 '11 at 10:57
@Midhat: Good question. You could access your account using imap, and get a list of all your labels like shown in this answer to a stackoverflow question. But there might be better ways though. – fretje Feb 21 '11 at 12:37
I got my plain text label list from Offline Gmail options. it lists all labels, comma seperated. – Midhat Feb 25 '11 at 19:41
Also the -label operator didnt work for me – Midhat Feb 25 '11 at 19:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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