How do I programmatically import picture files to Apple's Photos app?
The reason for this is that I have 20,000 old pictures. Most are in folders whose names have the data of when the pictures were taken or the file names themselves have the date and time stamps. So the idea is to import the pictures into Photos, but setting the folder/file name as the date and time taken.
Any hints? Thanks! Oh, and I'm doing this in Python.
If I have to move this to SuperUser, please let me know.
Late to the party, but I faced the problem myself and solved it as follows:
Two caveats:
When passing one image alone, it is imported immediately.
With multiple images, however, the import-UI is shown, where the user will have to confirm the import.
If Photos.app is running already, it is brought to the foreground without triggering any imports. If acceptable, it can be force-quit beforehand:
killall Photos
In the context of Python, system calls can be done using
This was just the importing step. For mangling with the metadata, pyexiv2 is a fantastic library.
See also: