The Goal: In macOS Photos App, highlight/select a bulk of photos, iterate each one. AppleScript will tell Photos to quickview the photo, ask what 'Album(s)' to add the photo to, then it will ask for a title and caption.
I'm doing this because the 'Info' panel that provides this function doesn't allow for rapid entry, and it's pretty small to work with.
So I suppose I need a couple things:
- Show the picture (tell Photos to quick look it)
- Identify the 'My Album' folders (eliminate the smart folders from the mix)
- Prompt and Update the Title and the Caption (called name and description in the def)
- Add the photo to the selected Albums.
I'm not sure if it's just me, but the AppleScript scripting on Photos is just not something I can wrap my head around very well.
Here's what I have so far, but I was hoping you can help.
tell application "Photos" --Find All Albums set thefullList to the name of every album of every folder -- Need:Figure out how to strip Smart Albums out of this query -- Set comma as the delim to separate the folders/albums set oldDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to "," set thefullList to every item of thefullList set AppleScript's text item delimiters to oldDelimiters -- Test the output (fails to delim, and won't display the string) display dialog thefullList -- Clean list of Albums set albumNames to {thefullList} -- Get the selected photos from Photos set theSelection to (get selection) -- Iterate through each photo repeat with i in theSelection -- Tell Photos to 'quick look' -- Need:(no idea how to make that work yet) -- Ask the user to choose the Album(s) this photo should go into set theAlbumChoice to choose from list albumNames with prompt "Where should this photo go?" -- Tell the Album that this photo is now added set theAlbum to theAlbumChoice add i to theAlbum -- Ask for Title and Caption display dialog "What's the Title of this Photo?" set theTitle to text returned of result display dialog "What's the Caption of this Photo?" set theCaption to text returned of result -- Get the Photo ID for adding MetaData set selectionID to id of item i of theSelection -- Set the Title and caption set name of media item id selectionID to theTitle set description of media item id selectionID to theCaption end repeat end tell 