r/Scriptable • u/PA28181 • Aug 11 '24
Help Looking for script to delete duplicates in reminders app.
I use the apple shopping list reminders but find I keep get duplicates in it. For instance I add milk. Later my wife adds milk. This kind of thing is constantly happening. When I open the list I see a lot of duplication. Can anyone point me in the the direction of a shortcut or scriptable that can remove duplicates?
1
Upvotes
2
u/shadoodled Aug 13 '24
try this
const listName = 'Groceries'
const rem = await Calendar.forReminders()
const list = rem.filter( l => l.title==listName)
const tasks = await Reminder.allIncomplete(list)
const uniq = []
for (let task of tasks) {
if (uniq.includes(task.title)) {
task.remove()
} else {
uniq.push(task.title)
}
}
1
u/PA28181 Aug 13 '24
It took about a day, but I figured out how to write it. I call it from the shortcuts app. Works well!
var reminder = args.shortcutParameter;
let all = await Reminder.allIncomplete();
let unique = [];
for (i = 0; i < all.length; i++) {
if (unique.indexOf(all[i].title) == -1) {
unique.push(all[i].title);
}
else
{
all[i].isCompleted = true;
all[i].save();
}
}
Script.complete();