All photos, videos and the associated meta data for the MacOS Photos library is stored in the
Photos Library directory under
Pictures in your home directory. However, the original files are placed in randomly named directories that are impossible to navigate outside of the Photos app.
For a simple backup I wanted to create a directory of all original photos and videos organised by year and month. So I wrote a PHP script which does the following:
- parses the Photos database file to find the location of all originals,
- creates symbolic links to the originals organized in directories named by year and month of the original
YYYY-MMand prefixes all filenames with an md5 hash of the file.
We end up with a flat directory structure that can be easily synced to any remote location using
rsync which takes care of resolving the symbolic links:
$ rsync --copy-links --archive links/ /path/to/destination
Now you’re able to do things like:
- merge multiple libraries,
- find items that are not present in one of the libraries.