-
-
Save Suleman-Elahi/cbd5758094a2325ce1678037f97aaa04 to your computer and use it in GitHub Desktop.
GMail Auto Archive script for Google Scripts
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 gmailAutoarchive() { | |
var threads = GmailApp.search("in:inbox label:autoarchive older_than:1d"); | |
Logger.log("found " + threads.length + " threads:"); | |
for(var i = 0; i < threads.length; i++) { | |
var thread = threads[i]; | |
Logger.log((i+1) + ". " + thread.getFirstMessageSubject()); | |
} | |
var batch_size = 100; | |
while (threads.length) { | |
var this_batch_size = Math.min(threads.length, batch_size); | |
var this_batch = threads.splice(0, this_batch_size); | |
GmailApp.moveThreadsToArchive(this_batch); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment