The Google Script will archive all email threads in a specific Gmail label that have been inactive for more than a week. It takes the date of the last message in a thread and if it is older than a week, the thread is archived. The current labels is removed as well.
function ArchiveOldEmails(gmailLabelName){ var gmailLabel = GmailApp.getUserLabelByName(gmailLabelName); var ONE_WEEK = 60 * 60 * 24 * 7 * 1000; var threads = label.getThreads(); var now = new Date(); for (var j=0; jONE_WEEK){ threads[j].moveToArchive().removeLabel(gmailLabel); } } }