Last active
August 4, 2018 08:34
-
-
Save sveitser/6c1370ce842614abf67df477024d0aaa to your computer and use it in GitHub Desktop.
Google app script to remove old forum messages. Paste into https://script.google.com and schedule or whatever.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cleanUp() { | |
// I think this refers to the date when the thread was started. | |
var delayDays = 90; | |
var max = 200; | |
var offset = 0; | |
var query = 'category:forums older_than:' + delayDays + 'd' | |
while (true) { | |
var threads = GmailApp.search(query, offset, max); | |
Logger.log("fetched %s", offset + threads.length); | |
for (var i = 0; i < threads.length; i++) { | |
Logger.log("removing %s", offset + i); | |
threads[i].moveToTrash(); | |
} | |
if (threads.length < max) { | |
break; | |
} | |
offset += max; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment