Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

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

Not the world's best way but, use the built in labels to your advantage. This assumes you don't care about labels that GMail applies, like Social, Updates, Promotions, or Forums. These labels are not considered USER LABELS (My example user label: Foo)

  1. go to All Mail - Select All Mail and then select 'Select all XXX Messages in All Mail' (apply to every piece of email you have)
  2. use the label menu to unselect one of the GMail Labels (above). I usually use Promotions.
  3. go to the label you are interested in searching (Foo)
  4. Select All and then 'Select all XXX Messages in (Foo)'
  5. use the label menu to select the cleared GMail Label from step #2 (Promotions) - and to unselect the current label (Foo)
  6. now you have all your (Foo) labelled messages, changed to the label (Promotions) - a label which is NOT a user label
  7. go to (Promotions) - add to search: 'has:nouserlabels'
  8. now you have a list of emails that used to be ONLY labelled as (Foo)
  9. go to (Promotions) - select All and then 'Select all XXX Messages in (Promotions)'
  10. use the label menu to add (Foo) to all messages. Everything is back to normal
share|improve this answer

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.