Photos and nested folders

I’m wondering did scripting for Photos change in Catalina? It is not finding nested folders. My partial layout for Photos is

My Albums

Photo Streams


If I do

tell application "Photos"
	set folderName to "2020"
	set theseFolders to every folder whose name is folderName
	set folderCount to the count of theseFolders
end tell

I get a count of 0. If I add a 2020 folder to the root of My Album, and search I get a count of 1. If I renamed the nested folder (grasping at straws, maybe Photos has problem of names only number in it) to “The year 2020” and searching for that returns a count of 0.

I thought every folder was suppose to find nested folders in Photos.

Thanks for whatever feedback.

With Kindest Regards,

Stephen Magladry

No, it doesn’t find, because doesn’t provide command entire contents like the Finder.

A wrote here the script to solve this problem:

property theFolders : {} -- for all folders list of nested structure

-- first, get all folders list using recursive handler
tell application "Photos"
	repeat with aFolder in (get folders)
		my getFolders(aFolder)
	end repeat
end tell

-- now, find the folder whose name is "2020"
repeat with aFolder in theFolders
	if name of aFolder is "2020" then return aFolder
end repeat

-- recursive handler to get all folders list of nested structure
on getFolders(aFolder)
	tell application "Photos"
		set end of theFolders to contents of aFolder
		set subFolders to folders of aFolder
		if not (subFolders is {}) then
			repeat with subFolder in subFolders
				my getFolders(subFolder)
			end repeat
		end if
	end tell
end getFolders