Extract the create date from Apple photo exports and updates the images by fixing their modified and created timestamps. Also, copy the files into a separate directory structure organized by year and month of when the images were taken.
These scripts were written and tested on Catalina MacOS.
Process the jpeg images from Apple Photos. These are the images generated by File->Export->Export Photo, and are the edited versions of the stored images. This export option will not export the unmodified image or the movie associated with the image when it was taken. See the unmodified.py section for processing unmodified images. Also, if you have recorded any movies, they will not be able to be processed as .mov files do not contain any metadata. Those will have to be processed again by unmodified.py and the using the unmodified image export.
$ pip install exifread
Process all unmodified images exported by Apple Photos. These are the images generated by File->Export->Export Unmodified Original menu option. As part of the export, there are generally three files that are generated per image. They are the unmodified jpeg, a .mov movie, and an .xmp file which contains the image metadata in xml format. This script first reads the entire source directory and creates a dictionary where it will store all the filenames and metadata that it needs to process. This optimizes it in case there are 10s of thousands of images stored on a separate server and you are accessing them via a mount point. Once the initial dictionary is created and the create dates are extracted from the .xmp files, the script moves on to copying the images into the destination folder structure.
$ pip install xmltodict