Created
July 23, 2019 05:19
-
-
Save MacularDegenerate/8ed1ea4c9f0c5ddd9eb6d69e1935df64 to your computer and use it in GitHub Desktop.
Archive completed Reminders greater than 7 days old
This file contains 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
// days: specifies the number of days that a reminder will remain marked as complete before it is moved to the "Completed Archive" list. | |
let days = 7 | |
let today = new Date() | |
let arch = await Calendar.forRemindersByTitle("Completed Archive") | |
let listsToClear = await Calendar.forReminders() | |
for ( var j = 0; j < listsToClear.length; j++ ) { | |
let cal = listsToClear[j] | |
let reminders = await Reminder.allCompleted( [cal] ) | |
for( var i = 0; i < reminders.length; i++ ) { | |
let reminder = reminders[i] | |
console.log( reminder.title ) | |
if ((today - reminder.completionDate)/(1000 * 3600 * 24) > days ) { | |
reminder.calendar = arch | |
reminder.isCompleted = 0 | |
reminder.save() | |
} | |
} | |
} | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment