Applescript to add image to album


I was hoping for some help. I am currently sorting through my photo library and would like to add various photos to about 3-4 albums. Up until now I have been manually dragging and dropping the selected photos into the albums, but I am sure there is a better way.

I think an AppleScript would be a better solution, triggered by a KM hotkey. I am not very strong with AppleScript and would appreciate some help. Ideally the script would work for one or multiple images which are selected. Oh, and I am using the standard Mac Photos.App.

Many thanks.

This isn’t a script, but a less tedious way to achieve your goal.

  1. Apply a keyword for each album, using the “single keystroke” to assign keyword to each photo. The keyword could even be a nonsense string.
  2. The Keyword window must be open for the keystroke method to work.
  3. Then, once all the photos are processed, you could search for each single keyword, “Select All”, and drag all at once to you album.
  4. Or, just make a smart album for each desired keyword.

This AppleScript works for me (adjust album name in line 2):

tell application "Photos"
	set theAlbum to first container whose name is "Instagram"
	set selectedItems to selection
	add selectedItems to theAlbum
end tell

Thanks to both @jeffbelden and @MarkusJ. I had actually started to use keywords in the manner described. Thanks for the apple script. I have modified to suit and it works well.

Much appreciated.