Forum Archive

I want to create folders of albums in Photos app

dotHTM

Does the photos module allow creation of "album folders"?

I've used the photos module to create albums, but folders are a special collection in the Photos app that contain albums or other folders.

I believe these can normally only be created in the GUI for macOS Photos.app, although they're displayed in iOS Photos.app with no problem.

cvp

I'm estonished my-self but this little script does what you want. I really don't know anything about objective-c and blocks but I just spent one hour with by my big friend Google and I find some code , some Apple Doc, an @omz example using ObjcBlock (barometer in this forum) and putting all of that together creates the miracle 😂
Hoping it helps you.

Nb: before it functions, I got a lot of errors, solved thanks to @dgelessus code here

from objc_util import *

def act():
    print('act')
    cl = ObjCClass('PHCollectionListChangeRequest')
    clr = cl.creationRequestForCollectionListWithTitle_('folder_of_albums')

def eoa():
    print('eoa')

handler_block = ObjCBlock(act, restype=None, argtypes=None)
end_block = ObjCBlock(eoa, restype=None, argtypes=None)

ObjCClass('PHPhotoLibrary').sharedPhotoLibrary().performChanges_completionHandler_(handler_block,end_block)
TonK

Is there also a way (with / without objc_util) using Pythonista not to create but to to list (existing) album folders from the Photos app.

cvp

@TonK

import photos
for collection in photos.get_albums():
    print(collection.title)