It would be helpful to automate favourites via AppleScript, akin to the reading list.
Concretely for my use case, I would like to be able to add items to the list of favourites via AppleScript, and clear the list; I’m sure others would find the full CRUD-functionality useful.
I use DevonThink (among many other things) to prepare for meetings and keep notes. Every morning I run an AppleScript to go through my calendar and create a group for every meeting that day (with a meeting notes document inside).
I currently add those groups manually to the favourites, to have quick access to them throughout the day.
What I’d like to do is to add to my script the functionality to remove all favourites (which would be yesterday’s meeting groups), and add all of today’s meeting groups to the favourites.
Because I can’t have it at the top of the navigation bar. The nice thing about the individual favourites is that they are right there, always in the same spot, no need for hunting.
I do use a tag as you describe, for other purposes, but for quick access, I prefer the favourites. So much, that I’m currently willing to do these steps manually.
In the 3.5 build, you can select multiple items in the Navigate sidebar so you can select multiple favorites and Control-click > Remove from Favorites.
I don’t know about AppleScript, but in JavaScript you could do something like this to create groups for all events of today named like the event title:
(() => {
const calApp = Application("Calendar");
const dtApp = Application("DEVONthink 3");
// Get current date and time
const today_raw = new Date();
// Set the time to 00:00:00
const today = new Date(today_raw.getFullYear(), today_raw.getMonth(), today_raw.getDate());
// Get tomorrows date
const tomorrow = new Date(today.valueOf() + 24 * 60 * 60 *1000);
// Get all events in _all_ calendars starting today and ending before tomorrow
// This is not particularly fast - if you're interested in only _one_ calendar, change the
// line accordingly
const todayEvents = calApp.calendars.events.whose({_and:
[
{startDate: { _greaterThan: today}},
{endDate: { _lessThan: tomorrow}},
]});
todayEvents().forEach(cal => cal.forEach(ev => {
// create a new group with the title of the event in the current database
// To create the group in another database, use
// "{in: databaseSpecifier}"
// To create it in another group hierarchy, use
// `/events/subevents/whatever/${ev.summary())`
dtApp.createLocation(`/${ev.summary()}`);
}))
})()
This is just a blueprint. You can tweak it in any way you want, for example add templates to the group after it is creted, add custom meta data depending on the event’s location… Or you could try to make “get tomorrow’s date” part more elegant – that is really a clutch now.
@Blanc: I hope you can enjoy the wealth of different brackets in the whose call – enough to help you through the day, I hope