I have a ton of filters created that label e-mails in my inbox as they come in, so that I can easily discern between what groups they belong to with a quick glimpse. There are e-mails that get nested under, e.g. LABEL, and these are e-mails I read once and then archive, or sometimes just mark as read and archive (the subject line sometimes is enough to know what's going on inside it). However, after a week or so, the messages labelled LABEL are no longer of interest to me, and I delete them to prevent piling up of read and archived useless messages/e-mails.

What I want to know, is if there is some automatic way to get this latter part accomplished, since I now need to delete e-mails older than 7 days nested under LABEL manually. I know I can use filters to, in addition to adding a label to them as they come in, also delete or archive the e-mails. But that's not what I want; I want to be able to accomplish something like this:

  1. E-mail comes in, filter acts upon it, and I see it labelled as LABEL as it drops into my inbox. This part is why a filter (as far as I could tell) is of no use for what I want, since I don't want the e-mail to skip the inbox;
  2. I either read it or mark it as read, and then manually archive it;
  3. It goes away from my inbox, but I can still access it through search, All Mail or LABEL;
  4. It gets deleted 7 days afterwards, automatically.

Is there anyway to accomplish this? Either via the tools GMail has by default, or by some other means?

  • 2
    Not possible with just Gmail; filters only act on messages as they come in. You'll need some sort of 3rd party tool.
    – ale
    May 11, 2015 at 0:18
  • Ok, so it would fall under the "by some other means" category. Do you know anything in particular that could be of help here? Scripts, apps, tools?
    – JNat
    May 11, 2015 at 0:52
  • 1
    A time-triggered script is the way to do it; if the script posted by aparente001 didn't already exist, I'd write something like that (with the change I indicated under the answer).
    – user79865
    May 31, 2015 at 2:06

1 Answer 1


Here's a script that is supposed to auto-purge older email messages: http://www.labnol.org/internet/gmail-auto-purge/27605/ I haven't tried it.

  • 1
    Tried this; it works. I only changed the deprecated method ScriptApp.getScriptTriggers() to ScriptApp.getProjectTriggers(). Also, I'd avoid using spaces in labels associated with this script [or at all] because Gmail changes spaces to hyphens in some places.
    – user79865
    May 31, 2015 at 2:05
  • @Idisagree Should all instances of getScript[something] be replaced with getProject[something]? (example: Session.getScriptTimeZone())
    – JNat
    Jun 22, 2015 at 21:28
  • 1
    @JNat No, that one is fine. Google's naming decisions are what they are... The idea seems to be that triggers are grouped by a project (which may involve several scripts), while Session.getScriptTimeZone() is something that refers to the specific script being executed right now.
    – user79865
    Jun 22, 2015 at 21:40
  • I used this with the changes @1999 left in the comments.
    – JNat
    Jun 25, 2015 at 8:50

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.