AppleScript + macOS Photos Documentation needed

Hello!

I would like to ask for some guidance on development documentation for writing a simple script for accessing my photos library using an apple script.

I want to go through albums AND folders but I'm not very familiar with apple script nor photos objects. I only have this script which used to iterate through all my albums regardless the folder they were living in.. but apparently since Catalina, albums inside folders are no linger visible through the albums array/list/whatever.

I have this fragment:
Code Block tell application "Photos"		log "		Inside Photos App"		set albumsCount to count every album		log "			There are " & albumsCount & " albums in your Photos library"						set albumIndex to 1		repeat with albumObject in albums

But it only shows one album which is the only album in the root of the library that is not inside a folder.

I would love if you could point me in the right direction to fix and continue my work.

Thank you.
Angel.
Photos distinguishes between albums and folders. Folders can contain other folders and they can also contain albums. Albums just contain photos (well, media items :-). So, this:

Code Block  tell application "Photos"		name of every albumend tell


returns a list of albums at the top level, while this:

Code Block  tell application "Photos"		name of every folderend tell


returns every folder at the top level. I have a folder called Web Photo Galleries so I write this to get all the albums in it:

Code Block  tell application "Photos"		name of every album of folder "Web Photo Galleries"end tell


and this to get the nested folders:

Code Block  tell application "Photos"		name of every folder of folder "Web Photo Galleries"end tell


If you want to find an album by name within this hierarchy, you can do a recursive search:

Code Block  on albumNamedIn(albumName, parentRef)		using terms from application "Photos"				tell parentRef						repeat with i in albums								set a to contents of i								if name of a is albumName then										return a								end if						end repeat						repeat with i in folders								set f to contents of i								if name of f is not "iPhoto Events" then										my albumNamedIn(albumName, f)										if result is not missing value then												return result										end if								end if						end repeat				end tell		end using terms from		return missing valueend albumNamedInon albumNamed(albumName)		albumNamedIn(albumName, application "Photos")end albumNamed


Note that I explicitly exclude searching into the iPhoto Events folder because it has way too many children.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
AppleScript + macOS Photos Documentation needed
 
 
Q