10

I'm on a list-serv that gets emails from crons for several hundred servers. The volume of emails is about 1G/week, so to keep from bumping up against my 15G disk quota, I have to delete messages periodically. I have a filter in Gmail that adds the label 'label:inbox-zbark' to these.

I use a search like this to find a week's worth of emails:

label:inbox-zbark before:2018/12/16 after:2018/12/09

Then I can select a week's worth of messages by using the 'select all' button (which chooses the 100 conversations on the current page), then clicking the 'Select all conversations that match this search' button. I click the delete button and confirm the bulk action.

The problem is that above about 1000 conversations (which may have 100 emails a piece) gmail will either refuse to delete messages, or will throw an oops error. I can usually delete conversations 100 at a time, but this is very time consuming, and, at a certain point, gmail becomes markedly less responsive.

Gmail's trash folder has similar issues. At a certain point, the 'empty trash' button stops working... I can click the button, gmail will report All messages have been deleted., but the messages still show in the trash folder.

I'm looking for a better way to mass delete emails, doing it through inbox is getting painful.

  • Did you ever find a solution? I have the same problem :( – rangfu May 28 '19 at 15:01
  • 1
    @rangfu - The answer below by Chris worked really well for me. – acm Sep 16 at 14:15
2
  • Go to https://script.google.com
  • Create a new script

    function deleteOldEmail() { var batchSize = 100 while (true) { var threads = GmailApp.search('before:2018/10/12'); for (j = 0; j < threads.length; j+=batchSize) { GmailApp.moveThreadsToTrash(threads.slice(j, j+batchSize)); } } }

Save the project and click "run".
You will need to give the script access to your Gmail. It might take a few hours/days to complete running.

| improve this answer | |
  • This is a fantastic answer and I'd propose that it become the accepted answer for this question, as there currently isn't one. I did make some small modifications in my usage. First, Google indicates on their docs (developers.google.com/apps-script/reference/gmail/…) that they would prefer you used the paged API that takes a starting point and a range rather than returning the entire search results, so I refactored the loop to behave that way. Second, the current quotas mean that it will only run for six minutes before needing a restart. Triggers hit quotas too. – acm Sep 16 at 13:58
  • @Barton Chittenden - I encourage you to accept this answer to your question, as it is definitely the best answer here. – acm Sep 21 at 17:15
0

I don't know if you fixed this or not, but I was running into the same problem. If I choose to "move" the conversations into trash rather than delete them, it works for me. Hope it helps.

| improve this answer | |

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.