Bulk Delete Nest Albums in Photos by Pattern? I made the mistake of importing my photo archive for over 11 years which I had organized by year and then by dated events from years of manual collecting with maybe 10-20 folders of photo "albums" per year. After importing where it "preserves" folder hierarchy to create Albums, I have two problems now.

First off, the way Photos makes albums from an import is beyond stupid as it creates this unnecessary level of folder nesting for each album so that every sub folder which contains just pictures gets converted to a folder level as named and then a single album of the same name! You'd think the last level of photos would be just albums, but no. I can't see how this is at all helpful. I would think all leaves at a folder level would be made an album inside its containing folder so folders would only be created if it contains a sub-folder. This... this is awful. If there was some way to get a "tree view" inside the album selection view I could at least manually fix this on a year-by-year basis by moving all albums to their appropriate year,  but this is a no-go in the GUI as far as I can tell.

The other problem is that was using Picasa (SHAME!) years ago and I forgot that it pollutes your archive with thumbnails all over the place. I was able to get rid of all of the thumbnail photos using Gemini II which does photo matching (great tool for doing this, by the way) but now I have all of these albums named .@_thumb in every nested album along with each single album of a folders of the same name as I described, compounding the pain. The result is not only visually painful, the extra overhead seems to make Photos a total pig now. Apparently it does NOT like having so many Albums.

I tried using the command line to see if Album names show up in the Photos Library.photoslibrary hierarchy but either they are not listed there or not named by Album name. Trying find ~/Pictures/Photos\ Library.photoslibrary/ -name *thumb comes up empty. If I could only access the Albums by some descriptor I could probably fix this with some transformation script but as it stands I don't even know what the data structure is for Albums.

Any ideas?
Launch Script Editor and create a new script.

Deleting folders named ".@_thumb"

Copy and paste the following script into Script Editor.

use Photos : application "Photos"


run Photos

recurse(application "Photos")
repeat with F in flatten(result)
    try
        delete F
    end try
end repeat


to recurse(_X)
    set _A to a reference to every folder of _X
    if not (_A exists) then return {}
    return (_A whose name = ".@_thumb") &amp; recurse(_A)
end recurse

to flatten(L)
    local L

    if L = {} then return {}
    if L's class ≠ list then return {L}
    flatten(item 1 of L) &amp; flatten(rest of L)
end flatten


Run the script (⌘R).

The second issue you mentioned is trickier because of a bug in AppleScript that returns an incorrect reference to newly created albums.  At the moment, I'm not sure of a workaround, but I will have a think and update this with any thoughts I glean.