Is it possible to create filters based on Labels and starred/un-starred status in Gmail or any other app (Android or GNU/Linux)?

My specific problem is this: I want to delete mails labelled lists after 15 days if they are not starred. (I apply the label using filters based on list:mailing list email header.)

6 Answers 6


You can combine filters:

label:lists AND is:starred

To choose those that aren't starred, add - before is:starred:

label:lists AND -is:starred
  • 3
    You are combining search terms, not filters. Filters are triggered on message arrival and can move, label, and otherwise manipulate the newly-arrived message. The OP is asking how to arrange to manipulate already-filtered mail automatically some time well after its initial arrival.
    – Jeremy W. Sherman
    Commented Feb 14, 2011 at 8:17
  • I'm not sure that the OP is using the term "filter" in the same way that you are (and that, admittedly, gmail does). He is asking how he can search for all mails with a certain label and that aren't starred and delete them automatically. This is an action that is taken 15 days after arrival, not on arrival. Commented Feb 14, 2011 at 8:31
  • 1
    I wanted this process to be done automatically. I don't want to search and delete it.
    – Akilan
    Commented Feb 14, 2011 at 11:18
  • @Akilan: In that case you have two problems: 1. how do I specify what to delete (and this answer tells you how). 2. how do you use this specification automatically every day, some time after arrival, and not at the time that a message arrives. I have no idea how to do that. Commented Feb 14, 2011 at 14:30
  • It seems the second thing cannot be done from gmail interface. :(
    – Akilan
    Commented Feb 16, 2011 at 9:59

Gmail filters only act on incoming mail, not on anything you've already received.

The only time it will affect emails you already have is when you create a filter and tell it to apply to all the emails you see when you test a filter.

A workaround is to search for all the emails that are older than a particular date with the label and star that you want.

label:lists is:starred before:2011/01/20

The above will pull up all emails that are labelled with "lists," are starred and arrived in your inbox before the date of 20 January 2011. Select all, then delete and you're done.

When searching with the before: parameter, make sure the date is in the YYYY/MM/DD format.

If you look at the URL it'll be something like this:


You can bookmark that to easily access the search pre-filled. However, the date is locked in and you'll just need to update that next time you want to run the next purge.


As of late 2012 (according to this), you can now do what Lucas R suggested, but without having to keep changing the filter.

Just use the new search term older_than:, as in older_than:15d for your case.

For your case, you would search for (or use as a filter):
label:lists -is:starred older_than:15d


is:starred matches any conversation where at least one e-mail in it has a star,
so -is:starred matches any conversation where not every e-mail in it has a star. (I just tested this.)

If you can count on every single e-mail in the conversations you do not want deleted being starred (i.e. if all e-mails with your lists tag will be stand-alone and never have replies or forwards, or if they do have replies or forwards you will make sure to star every e-mail in the conversation (doubtful!)) then it is safe to use the search above for your deletion filter.

If you can't count on that, then you need to do something else, such as this:

  • make a new filter that searches for label:lists is:starred and applies a new tag/label (such as listsStarred)
  • for the main search/filter, instead of label:lists -is:starred older_than:15d (above), use label:lists -label:listsStarred older_than:15d

(There may still be a problem with getting the first filter to run before the second filter, though. See these questions on that issue:)


I just read your response, for the "is:starred" information. I have another idea for how to execute a batch delete as you propose. It is a manual method, but perhaps easier.

  1. Set up a filter for label:lists -is:starred before:yyyy/mm/dd, with the only action being delete.
  2. This filter will not do anything to new mail, however, it store the filter.
  3. When you want to use it, go to the filter and select edit, then edit the date and select the checkbox that says also apply to matching emails. Click update filter and it will run on your existing emails.

I was just trying to do the same thing and found a work-around! Okay maybe I haven't figured out the 2nd part about deleting the list after x amount of days. But I was able to filter based on label.

In your gmail, click on the down arrow in the search box. Under Search, there's a drop-down menu, select your label, starred, etc. Then click create filter with this search. It'll give you a warning that this is not recommended to use labels and stars as the only search criteria. Ignore it, and click continue anyway. From there you should be able to apply the regular filter actions.

It worked for me...This was actually my workaround for "converting an event to a task." I set the events to send me an email reminder, and if I'm done, I apply a label for task completed and I want those to just go into archive so I don't see them in my inbox anymore--but I still have a record of completed tasks. Hope this was somewhat useful.


You could solve the problem with a google app script.

I am using the following to merge Receipts I tag in my Mailbox app with receipts I tag in Gmail directly automatically.

function addReceiptLabelToMailboxReceipts() {

  var mailboxLabel = GmailApp.getUserLabelByName("[Mailbox]/Receipts");
  var stdLabel     = GmailApp.getUserLabelByName("Receipts");



You would need to iterate through and compare the dates, something like the following will get you most of the way.

var threads = label.getThreads();  
for (var i = 0; i < threads.length; i++) {  
    var messages = threads[i].getMessages();  
    var message = messages[0];

    var date = message.getDate();


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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