Sunday, October 29, 2023

Scripting Photos.app in Ventura (and maybe Sonoma) with AppleScript, Automator, and Shortcuts

[This post will be gradually developed. At the moment search engines return almost nothing on the current mess topic so even in its initial state it should be helpful.]

I recently moved my Aperture Photo Library from a machine running Mojave (last version OS with Aperture support) to one running Ventura and Photos.app. The migration was unspeakable.

Under Monterey there were a number of AppleScripts that mitigated key missing features in Photos (like batch rename). Some seem to ship from Apple with the OS. Others could be found online. Several appear in a compendium of user tips and scripts from Apple Discussions. But things have changed since Mojave and Monterey...

This blog post is going to be about scripting in Photos.app for Ventura and Monterey. In my own experimentation I was able to convert a 2019 Automator.app script containing AppleScript (basically it's a wrapper around a traditional AppleScript) into a Shortcuts.app script that runs as a service within Photos.app. To do this I had to enable AppleScript for use with Shortcuts and in Shortcuts details I could add it to the services menu. (Howard Oakley has an overview of the AppleScript to Shortcuts transition and an earlier article on Shortcuts in particular. The Shortcuts user guide article on this seems to have come from Automator but does actually work.)

I wasn't able to get the directions for adding Automator Quick Action Workflows in the Ventura Automator User Guide to work.

So I can batch rename images now from an entry in the Services menu. Yay.

If I find a good repository of Shortcuts I'll link to that. Otherwise I will try hosting them on my personal site or GitHub. I have an Apple Discussions question on the topic.