Moving Reminders between Lists

One of the challenges with straight shortcuts is while I can do remarkable things with searching reminders , I can’t change them easily. For example, I’d like to create a shortcut to scan my reminders inbox list based on a key word (i.e. @call) and move any reminders with that keyword to my list named Calls. From what I can see, this should be possible with Scriptable?

Thanks

It is. :blush:

Here’s a sample script.

// Gets all Reminders
let reminders = await Reminder.allIncomplete()

// Loop through to find tasks that have specified tag
for (reminder of reminders) {
    if (reminder.title.includes("#watch")) {
        // Find the calendar list to move the reminder to
        let cal = await Calendar.findOrCreateForReminders("Watch List")

        reminder.calendar = cal
        reminder.save()
    }
}
2 Likes

Just for fun, here’s another version of @kennonb 's code. The only real (potential) benefit is that it only looks up the calendar once, which could theoretically make it run faster. But I believe that’s already super quick, so probably wouldn’t be a noticeable difference.

// Get calendar once
const watchListCal = await Calendar.findOrCreateForReminders("Watch List");

// Gets #watch Reminders
const watchReminders = (await Reminder.allIncomplete()).filter(({ title }) =>
  title.includes("#watch")
);

// Function to move one reminder to the Watch list
const moveReminderToWatchList = reminder => {
  reminder.calendar = watchListCal;
  reminder.save();
};

// Loop through each reminder and move it
watchReminders.forEach(moveReminderToWatchList);

Or a more generic version so you could apply to other tags/lists:

const moveReminders = async (reminders, listName) => {
  const calObject = await Calendar.findOrCreateForReminders(listName);
  reminders.forEach(reminder => {
    reminder.calendar = calObject;
    reminder.save();
  });
};

const moveRemindersWithTag = async (tag, targetListName) => {
  const allReminders = await Reminder.allIncomplete();
  const matchingReminders = allReminders.filter(({ title }) =>
    title.includes(tag)
  );
  if (!matchingReminders.length) return;
  await moveReminders(matchingReminders, targetListName);
};

await moveRemindersWithTag("#watch", "Watch List");
2 Likes