Photos Utility Script Library The scripting support built into the Photos application is designed to provide users with the means for automating specific functions and tasks, both simple and complex. And to make it possible to create automation scripts with simpler and less scripting code, the Photos Utilities script library is comprised of suites of scripting commands designed to augment the existing scripting support in the Photos application in creative and powerful ways. Some of the script library’s published commands are shortcuts for dealing with common Photos items like folder and albums, while other commands make the process of exporting images to disk or into iWork documents, as simple as writing a single line of script code. And even though the Photos Utilities script library is written using the super-powerful AppleScriptObj-C (see sidebar), it can be referenced and called from within scripts written in either of the native scripting languages of OS X: AppleScript or JavaScript for Automation (JXA) NOTE: The Photos Utilities script library requires the installation of OS X v10.11 El Capitan or newer. Installing the Script Library To install this script library:
Using the Library with AppleScript When using the library with AppleScript, insert the following loading statement at the top of any AppleScript scripts that will be incorporating commands from this library: use script "Photos Utilities" Once the library has been installed in the user’s Library folder, and referenced at the beginning of the script, you can use the library’s commands throughout the script, like this: Using the Library with JavaScript for Automation (JXA) And here’s a version of the same script written in JavaScript for Automation (JXA). Note that the JXA script stores a reference to the script library in a standard JavaScript variable, like this: var PhotosUtilities = Library("Photos Utilities") Begin exploration of the various library commands by examining the Photos Utility Suite (link below). |