Created
June 18, 2017 11:11
-
-
Save schlos/befaea02ca0b39e72d9f54be24a596b6 to your computer and use it in GitHub Desktop.
Clean GMail
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
// This script retrieves contents of Gmail Inbox and leaves only | |
// predefined amount of last messages. Old messages will be | |
// moved to archive. | |
function cleanOld(){ | |
var old_threads = GmailApp.getInboxThreads(); | |
var leave = 30; | |
if (old_threads.length>=leave){ | |
for (var i=leave; i<old_threads.length; i++){ | |
if (!old_threads[i].isImportant()){ | |
old_threads[i].moveToArchive(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment