osxphotos export

osxphotos

osxphotos [OPTIONS] COMMAND [ARGS]...

Options

--db <Photos database path>

Specify Photos database path. Path to Photos library/database can be specified using either –db or directly as PHOTOS_LIBRARY positional argument. If neither –db or PHOTOS_LIBRARY provided, will attempt to find the library to use in the following order: 1. last opened library, 2. system library, 3. ~/Pictures/Photos Library.photoslibrary

--json

Print output in JSON format.

-v, --version

Show the version and exit.

export

Export photos from the Photos database. Export path DEST is required. Optionally, query the Photos database using 1 or more search options; if more than one option is provided, they are treated as “AND” (e.g. search for photos matching all options). If no query options are provided, all photos will be exported. By default, all versions of all photos will be exported including edited versions, live photo movies, burst photos, and associated raw images. See –skip-edited, –skip-live, –skip-bursts, and –skip-raw options to modify this behavior.

osxphotos export [OPTIONS] [PHOTOS_LIBRARY]... DEST

Options

--db <Photos database path>

Specify Photos database path. Path to Photos library/database can be specified using either –db or directly as PHOTOS_LIBRARY positional argument. If neither –db or PHOTOS_LIBRARY provided, will attempt to find the library to use in the following order: 1. last opened library, 2. system library, 3. ~/Pictures/Photos Library.photoslibrary

-V, --verbose

Print verbose output.

--timestamp

Add time stamp to verbose output

--no-progress

Do not display progress bar during export.

--keyword <KEYWORD>

Search for photos with keyword KEYWORD. If more than one keyword, treated as “OR”, e.g. find photos matching any keyword

--person <PERSON>

Search for photos with person PERSON. If more than one person, treated as “OR”, e.g. find photos matching any person

--album <ALBUM>

Search for photos in album ALBUM. If more than one album, treated as “OR”, e.g. find photos matching any album

--folder <FOLDER>

Search for photos in an album in folder FOLDER. If more than one folder, treated as “OR”, e.g. find photos in any FOLDER. Only searches top level folders (e.g. does not look at subfolders)

--name <FILENAME>

Search for photos with filename matching FILENAME. If more than one –name options is specified, they are treated as “OR”, e.g. find photos matching any FILENAME.

--uuid <UUID>

Search for photos with UUID(s). May be repeated to include multiple UUIDs.

--uuid-from-file <FILE>

Search for photos with UUID(s) loaded from FILE. Format is a single UUID per line. Lines preceded with # are ignored.

--title <TITLE>

Search for TITLE in title of photo.

--no-title

Search for photos with no title.

--description <DESC>

Search for DESC in description of photo.

--no-description

Search for photos with no description.

--place <PLACE>

Search for PLACE in photo’s reverse geolocation info

--no-place

Search for photos with no associated place name info (no reverse geolocation info)

--location

Search for photos with associated location info (e.g. GPS coordinates)

--no-location

Search for photos with no associated location info (e.g. no GPS coordinates)

--label <LABEL>

Search for photos with image classification label LABEL (Photos 5 only). If more than one label, treated as “OR”, e.g. find photos matching any label

--uti <UTI>

Search for photos whose uniform type identifier (UTI) matches UTI

-i, --ignore-case

Case insensitive search for title, description, place, keyword, person, or album.

--edited

Search for photos that have been edited.

--external-edit

Search for photos edited in external editor.

--favorite

Search for photos marked favorite.

--not-favorite

Search for photos not marked favorite.

--hidden

Search for photos marked hidden.

--not-hidden

Search for photos not marked hidden.

--shared

Search for photos in shared iCloud album (Photos 5 only).

--not-shared

Search for photos not in shared iCloud album (Photos 5 only).

--burst

Search for photos that were taken in a burst.

--not-burst

Search for photos that are not part of a burst.

--live

Search for Apple live photos

--not-live

Search for photos that are not Apple live photos.

--portrait

Search for Apple portrait mode photos.

--not-portrait

Search for photos that are not Apple portrait mode photos.

--screenshot

Search for screenshot photos.

--not-screenshot

Search for photos that are not screenshot photos.

--slow-mo

Search for slow motion videos.

--not-slow-mo

Search for photos that are not slow motion videos.

--time-lapse

Search for time lapse videos.

--not-time-lapse

Search for photos that are not time lapse videos.

--hdr

Search for high dynamic range (HDR) photos.

--not-hdr

Search for photos that are not HDR photos.

--selfie

Search for selfies (photos taken with front-facing cameras).

--not-selfie

Search for photos that are not selfies.

--panorama

Search for panorama photos.

--not-panorama

Search for photos that are not panoramas.

--has-raw

Search for photos with both a jpeg and raw version

--only-movies

Search only for movies (default searches both images and movies).

--only-photos

Search only for photos/images (default searches both images and movies).

--from-date <from_date>

Search by item start date, e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--to-date <to_date>

Search by item end date, e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--from-time <from_time>

Search by item start time of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>

Search by item end time of day, e.g. 12:00 or 12:00:00.

--year <YEAR>

Search for items from a specific year, e.g. –year 2022 to find all photos from the year 2022. May be repeated to search multiple years.

--has-comment

Search for photos that have comments.

--no-comment

Search for photos with no comments.

--has-likes

Search for photos that have likes.

--no-likes

Search for photos with no likes.

--is-reference

Search for photos that were imported as referenced files (not copied into Photos library).

--in-album

Search for photos that are in one or more albums.

--not-in-album

Search for photos that are not in any albums.

--duplicate

Search for photos with possible duplicates. osxphotos will compare signatures of photos, evaluating date created, size, height, width, and edited status to find possible duplicates. This does not compare images byte-for-byte nor compare hashes but should find photos imported multiple times or duplicated within Photos.

--min-size <SIZE>

Search for photos with size >= SIZE bytes. The size evaluated is the photo’s original size (when imported to Photos). Size may be specified as integer bytes or using SI or NIST units. For example, the following are all valid and equivalent sizes: ‘1048576’ ‘1.048576MB’, ‘1 MiB’.

--max-size <SIZE>

Search for photos with size <= SIZE bytes. The size evaluated is the photo’s original size (when imported to Photos). Size may be specified as integer bytes or using SI or NIST units. For example, the following are all valid and equivalent sizes: ‘1048576’ ‘1.048576MB’, ‘1 MiB’.

--regex <REGEX TEMPLATE>

Search for photos where TEMPLATE matches regular expression REGEX. For example, to find photos in an album that begins with ‘Beach’: ‘–regex “^Beach” “{album}”’. You may specify more than one regular expression match by repeating ‘–regex’ with different arguments.

--selected

Filter for photos that are currently selected in Photos.

--exif <EXIF_TAG VALUE>

Search for photos where EXIF_TAG exists in photo’s EXIF data and contains VALUE. For example, to find photos created by Adobe Photoshop: –exif Software ‘Adobe Photoshop’ `or to find all photos shot on a Canon camera: `–exif Make Canon. EXIF_TAG can be any valid exiftool tag, with or without group name, e.g. EXIF:Make or Make. To use –exif, exiftool must be installed and in the path.

--query-eval <CRITERIA>

Evaluate CRITERIA to filter photos. CRITERIA will be evaluated in context of the following python list comprehension: photos = [photo for photo in photos if CRITERIA] where photo represents a PhotoInfo object. For example: –query-eval photo.favorite returns all photos that have been favorited and is equivalent to –favorite. You may specify more than one CRITERIA by using –query-eval multiple times. CRITERIA must be a valid python expression. See https://rhettbull.github.io/osxphotos/ for additional documentation on the PhotoInfo class.

--query-function <filename.py::function>

Run function to filter photos. Use this in format: –query-function filename.py::function where filename.py is a python file you’ve created and function is the name of the function in the python file you want to call. Your function will be passed a list of PhotoInfo objects and is expected to return a filtered list of PhotoInfo objects. You may use more than one function by repeating the –query-function option with a different value. Your query function will be called after all other query options have been evaluated. See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of how to use this option.

--missing

Export only photos missing from the Photos library; must be used with –download-missing.

--deleted

Include photos from the ‘Recently Deleted’ folder.

--deleted-only

Include only photos from the ‘Recently Deleted’ folder.

--update

Only export new or updated files. See also –force-update and notes below on export and –update.

--force-update

Only export new or updated files. Unlike –update, –force-update will re-export photos if their metadata has changed even if this would not otherwise trigger an export. See also –update and notes below on export and –update.

--ignore-signature

When used with ‘–update’, ignores file signature when updating files. This is useful if you have processed or edited exported photos changing the file signature (size & modification date). In this case, ‘–update’ would normally re-export the processed files but with ‘–ignore-signature’, files which exist in the export directory will not be re-exported. If used with ‘–sidecar’, ‘–ignore-signature’ has the following behavior: 1) if the metadata (in Photos) that went into the sidecar did not change, the sidecar will not be updated; 2) if the metadata (in Photos) that went into the sidecar did change, a new sidecar is written but a new image file is not; 3) if a sidecar does not exist for the photo, a sidecar will be written whether or not the photo file was written or updated.

--only-new

If used with –update, ignores any previously exported files, even if missing from the export folder and only exports new files that haven’t previously been exported.

--dry-run

Dry run (test) the export but don’t actually export any files; most useful with –verbose.

Hardlink files instead of copying them. Cannot be used with –exiftool which creates copies of the files with embedded EXIF data. Note: on APFS volumes, files are cloned when exporting giving many of the same advantages as hardlinks without having to use –export-as-hardlink.

--touch-file

Sets the file’s modification time to match photo date.

--overwrite

Overwrite existing files. Default behavior is to add (1), (2), etc to filename if file already exists. Use this with caution as it may create name collisions on export. (e.g. if two files happen to have the same name)

--retry <RETRY>

Automatically retry export up to RETRY times if an error occurs during export. This may be useful with network drives that experience intermittent errors.

--export-by-date

Automatically create output folders to organize photos by date created (e.g. DEST/2019/12/20/photoname.jpg).

--skip-edited

Do not export edited version of photo if an edited version exists.

--skip-original-if-edited

Do not export original if there is an edited version (exports only the edited version).

--skip-bursts

Do not export all associated burst images in the library if a photo is a burst photo.

--skip-live

Do not export the associated live video component of a live photo.

--skip-raw

Do not export associated RAW image of a RAW+JPEG pair. Note: this does not skip RAW photos if the RAW photo does not have an associated JPEG image (e.g. the RAW file was imported to Photos without a JPEG preview).

--skip-uuid <UUID>

Skip photos with UUID(s) during export. May be repeated to include multiple UUIDs.

--skip-uuid-from-file <FILE>

Skip photos with UUID(s) loaded from FILE. Format is a single UUID per line. Lines preceded with # are ignored.

--current-name

Use photo’s current filename instead of original filename for export. Note: Starting with Photos 5, all photos are renamed upon import. By default, photos are exported with the the original name they had before import.

--convert-to-jpeg

Convert all non-JPEG images (e.g. RAW, HEIC, PNG, etc) to JPEG upon export. Note: does not convert the RAW component of a RAW+JPEG pair as the associated JPEG image will be exported. You can use –skip-raw to skip exporting the associated RAW image of a RAW+JPEG pair. See also –jpeg-quality and –jpeg-ext. Only works if your Mac has a GPU (thus may not work on virtual machines).

--jpeg-quality <jpeg_quality>

Value in range 0.0 to 1.0 to use with –convert-to-jpeg. A value of 1.0 specifies best quality, a value of 0.0 specifies maximum compression. Defaults to 1.0

--preview

Export preview image generated by Photos. This is a lower-resolution image used by Photos to quickly preview the image. See also –preview-suffix and –preview-if-missing.

--preview-if-missing

Export preview image generated by Photos if the actual photo file is missing from the library. This may be helpful if photos were not copied to the Photos library and the original photo is missing. See also –preview-suffix and –preview.

--preview-suffix <SUFFIX>

Optional suffix template for naming preview photos. Default name for preview photos is in form ‘photoname_preview.ext’. For example, with ‘–preview-suffix _low_res’, the preview photo would be named ‘photoname_low_res.ext’. The default suffix is ‘_preview’. Multi-value templates (see Templating System) are not permitted with –preview-suffix. See also –preview and –preview-if-missing.

--download-missing

Attempt to download missing photos from iCloud. The current implementation uses Applescript to interact with Photos to export the photo which will force Photos to download from iCloud if the photo does not exist on disk. This will be slow and will require internet connection. This obviously only works if the Photos library is synched to iCloud. Note: –download-missing does not currently export all burst images; only the primary photo will be exported–associated burst images will be skipped.

--sidecar <FORMAT>

Create sidecar for each photo exported; valid FORMAT values: xmp, json, exiftool; –sidecar xmp: create XMP sidecar used by Digikam, Adobe Lightroom, etc. The sidecar file is named in format photoname.ext.xmp The XMP sidecar exports the following tags: Description, Title, Keywords/Tags, Subject (set to Keywords + PersonInImage), PersonInImage, CreateDate, ModifyDate, GPSLongitude, Face Regions (Metadata Working Group and Microsoft Photo). –sidecar json: create JSON sidecar useable by exiftool (https://exiftool.org/) The sidecar file can be used to apply metadata to the file with exiftool, for example: “exiftool -j=photoname.jpg.json photoname.jpg” The sidecar file is named in format photoname.ext.json; format includes tag groups (equivalent to running ‘exiftool -G -j’). –sidecar exiftool: create JSON sidecar compatible with output of ‘exiftool -j’. Unlike ‘–sidecar json’, ‘–sidecar exiftool’ does not export tag groups. Sidecar filename is in format photoname.ext.json; For a list of tags exported in the JSON and exiftool sidecar, see ‘–exiftool’. See also ‘–ignore-signature’.

Options

xmp | json | exiftool

--sidecar-drop-ext

Drop the photo’s extension when naming sidecar files. By default, sidecar files are named in format ‘photo_filename.photo_ext.sidecar_ext’, e.g. ‘IMG_1234.JPG.xmp’. Use ‘–sidecar-drop-ext’ to ignore the photo extension. Resulting sidecar files will have name in format ‘IMG_1234.xmp’. Warning: this may result in sidecar filename collisions if there are files of different types but the same name in the output directory, e.g. ‘IMG_1234.JPG’ and ‘IMG_1234.MOV’.

--exiftool

Use exiftool to write metadata directly to exported photos. To use this option, exiftool must be installed and in the path. exiftool may be installed from https://exiftool.org/. Cannot be used with –export-as-hardlink. Writes the following metadata: EXIF:ImageDescription, XMP:Description (see also –description-template); XMP:Title; XMP:TagsList, IPTC:Keywords, XMP:Subject (see also –keyword-template, –person-keyword, –album-keyword); XMP:PersonInImage; EXIF:GPSLatitudeRef; EXIF:GPSLongitudeRef; EXIF:GPSLatitude; EXIF:GPSLongitude; EXIF:GPSPosition; EXIF:DateTimeOriginal; EXIF:OffsetTimeOriginal; EXIF:ModifyDate (see –ignore-date-modified); IPTC:DateCreated; IPTC:TimeCreated; (video files only): QuickTime:CreationDate; QuickTime:CreateDate; QuickTime:ModifyDate (see also –ignore-date-modified); QuickTime:GPSCoordinates; UserData:GPSCoordinates.

--exiftool-path <EXIFTOOL_PATH>

Optionally specify path to exiftool; if not provided, will look for exiftool in $PATH.

--exiftool-option <OPTION>

Optional flag/option to pass to exiftool when using –exiftool. For example, –exiftool-option ‘-m’ to ignore minor warnings. Specify these as you would on the exiftool command line. See exiftool docs at https://exiftool.org/exiftool_pod.html for full list of options. More than one option may be specified by repeating the option, e.g. –exiftool-option ‘-m’ –exiftool-option ‘-F’.

--exiftool-merge-keywords

Merge any keywords found in the original file with keywords used for ‘–exiftool’ and ‘–sidecar’.

--exiftool-merge-persons

Merge any persons found in the original file with persons used for ‘–exiftool’ and ‘–sidecar’.

--ignore-date-modified

If used with –exiftool or –sidecar, will ignore the photo modification date and set EXIF:ModifyDate to EXIF:DateTimeOriginal; this is consistent with how Photos handles the EXIF:ModifyDate tag.

--person-keyword

Use person in image as keyword/tag when exporting metadata.

--album-keyword

Use album name as keyword/tag when exporting metadata.

--keyword-template <TEMPLATE>

For use with –exiftool, –sidecar; specify a template string to use as keyword in the form ‘{name,DEFAULT}’ This is the same format as –directory. For example, if you wanted to add the full path to the folder and album photo is contained in as a keyword when exporting you could specify –keyword-template “{folder_album}” You may specify more than one template, for example –keyword-template “{folder_album}” –keyword-template “{created.year}”. See ‘–replace-keywords’ and Templating System below.

--replace-keywords

Replace keywords with any values specified with –keyword-template. By default, –keyword-template will add keywords to any keywords already associated with the photo. If –replace-keywords is specified, values from –keyword-template will replace any existing keywords instead of adding additional keywords.

--description-template <TEMPLATE>

For use with –exiftool, –sidecar; specify a template string to use as description in the form ‘{name,DEFAULT}’ This is the same format as –directory. For example, if you wanted to append ‘exported with osxphotos on [today’s date]’ to the description, you could specify –description-template “{descr} exported with osxphotos on {today.date}” See Templating System below.

--finder-tag-template <TEMPLATE>

Set MacOS Finder tags to TEMPLATE. These tags can be searched in the Finder or Spotlight with ‘tag:tagname’ format. For example, ‘–finder-tag-template “{label}”’ to set Finder tags to photo labels. You may specify multiple TEMPLATE values by using ‘–finder-tag-template’ multiple times. See also ‘–finder-tag-keywords and Extended Attributes below.’.

--finder-tag-keywords

Set MacOS Finder tags to keywords; any keywords specified via ‘–keyword-template’, ‘–person-keyword’, etc. will also be used as Finder tags. See also ‘–finder-tag-template and Extended Attributes below.’.

--xattr-template <ATTRIBUTE TEMPLATE>

Set extended attribute ATTRIBUTE to TEMPLATE value. Valid attributes are: ‘authors’, ‘comment’, ‘copyright’, ‘creator’, ‘description’, ‘findercomment’, ‘headline’, ‘keywords’, ‘participants’, ‘projects’, ‘rating’, ‘subject’, ‘title’, ‘version’. For example, to set Finder comment to the photo’s title and description: ‘–xattr-template findercomment “{title}; {descr}” See Extended Attributes below for additional details on this option.

--directory <DIRECTORY>

Optional template for specifying name of output directory in the form ‘{name,DEFAULT}’. See below for additional details on templating system.

--filename <FILENAME>

Optional template for specifying name of output file in the form ‘{name,DEFAULT}’. File extension will be added automatically–do not include an extension in the FILENAME template. See below for additional details on templating system.

--jpeg-ext <EXTENSION>

Specify file extension for JPEG files. Photos uses .jpeg for edited images but many images are imported with .jpg or .JPG which can result in multiple different extensions used for JPEG files upon export. Use –jpeg-ext to specify a single extension to use for all exported JPEG images. Valid values are jpeg, jpg, JPEG, JPG; e.g. ‘–jpeg-ext jpg’ to use ‘.jpg’ for all JPEGs.

Options

jpeg | jpg | JPEG | JPG

--strip

Optionally strip leading and trailing whitespace from any rendered templates. For example, if –filename template is “{title,} {original_name}” and image has no title, resulting file would have a leading space but if used with –strip, this will be removed.

--edited-suffix <SUFFIX>

Optional suffix template for naming edited photos. Default name for edited photos is in form ‘photoname_edited.ext’. For example, with ‘–edited-suffix _bearbeiten’, the edited photo would be named ‘photoname_bearbeiten.ext’. The default suffix is ‘_edited’. Multi-value templates (see Templating System) are not permitted with –edited-suffix.

--original-suffix <SUFFIX>

Optional suffix template for naming original photos. Default name for original photos is in form ‘filename.ext’. For example, with ‘–original-suffix _original’, the original photo would be named ‘filename_original.ext’. The default suffix is ‘’ (no suffix). Multi-value templates (see Templating System) are not permitted with –original-suffix.

--use-photos-export

Force the use of AppleScript or PhotoKit to export even if not missing (see also ‘–download-missing’ and ‘–use-photokit’).

--use-photokit

Use with ‘–download-missing’ or ‘–use-photos-export’ to use direct Photos interface instead of AppleScript to export. Highly experimental alpha feature; does not work with iTerm2 (use with Terminal.app). This is faster and more reliable than the default AppleScript interface.

--report <path to export report>

Write a CSV formatted report of all files that were exported.

--cleanup

Cleanup export directory by deleting any files which were not included in this export set. For example, photos which had previously been exported and were subsequently deleted in Photos. WARNING: –cleanup will delete any files in the export directory that were not exported by osxphotos, for example, your own scripts or other files. Be sure this is what you intend before using –cleanup. Use –dry-run with –cleanup first if you’re not certain.

--add-exported-to-album <ALBUM>

Add all exported photos to album ALBUM in Photos. Album ALBUM will be created if it doesn’t exist. All exported photos will be added to this album. This only works if the Photos library being exported is the last-opened (default) library in Photos. This feature is currently experimental. I don’t know how well it will work on large export sets.

--add-skipped-to-album <ALBUM>

Add all skipped photos to album ALBUM in Photos. Album ALBUM will be created if it doesn’t exist. All skipped photos will be added to this album. This only works if the Photos library being exported is the last-opened (default) library in Photos. This feature is currently experimental. I don’t know how well it will work on large export sets.

--add-missing-to-album <ALBUM>

Add all missing photos to album ALBUM in Photos. Album ALBUM will be created if it doesn’t exist. All missing photos will be added to this album. This only works if the Photos library being exported is the last-opened (default) library in Photos. This feature is currently experimental. I don’t know how well it will work on large export sets.

--post-command <CATEGORY COMMAND>

Run COMMAND on exported files of category CATEGORY. CATEGORY can be one of: exported, new, updated, skipped, missing, exif_updated, touched, converted_to_jpeg, sidecar_json_written, sidecar_json_skipped, sidecar_exiftool_written, sidecar_exiftool_skipped, sidecar_xmp_written, sidecar_xmp_skipped, error. COMMAND is an osxphotos template string, for example: ‘–post-command exported “echo {filepath|shell_quote} >> {export_dir}/exported.txt”’, which appends the full path of all exported files to the file ‘exported.txt’. You can run more than one command by repeating the ‘–post-command’ option with different arguments. See Post Command below.

--post-function <filename.py::function>

Run function on exported files. Use this in format: –post-function filename.py::function where filename.py is a python file you’ve created and function is the name of the function in the python file you want to call. The function will be passed information about the photo that’s been exported and a list of all exported files associated with the photo. You can run more than one function by repeating the ‘–post-function’ option with different arguments. See Post Function below.

--exportdb <EXPORTDB_FILE>

Specify alternate path for database file which stores state information for export and –update. If –exportdb is not specified, export database will be saved to ‘.osxphotos_export.db’ in the export directory. If –exportdb is specified, it will be saved to the specified file.

--ramdb

Copy export database to memory during export; may improve performance when exporting over a network or slow disk but could result in losing update state information if the program is interrupted or crashes.

--tmpdir <DIR>

Specify alternate temporary directory. Default is system temporary directory. osxphotos needs to create a number of temporary files during export. In some cases, particularly if the Photos library is on an APFS volume that is not the system volume, osxphotos may run faster if you specify a temporary directory on the same volume as the Photos library.

--load-config <config file path>

Load options from file as written with –save-config. This allows you to save a complex export command to file for later reuse. For example: ‘osxphotos export <lots of options here> –save-config osxphotos.toml’ then ‘osxphotos export /path/to/export –load-config osxphotos.toml’. If any other command line options are used in conjunction with –load-config, they will override the corresponding values in the config file.

--save-config <config file path>

Save options to file for use with –load-config. File format is TOML. See also –config-only.

--config-only

If specified, saves the config file but does not export any files; must be used with –save-config.

--theme <THEME>

Specify the color theme to use for –verbose output. Valid themes are ‘dark’, ‘light’, ‘mono’, and ‘plain’. Defaults to ‘dark’ or ‘light’ depending on system dark mode setting.

Options

dark | light | mono | plain

Arguments

PHOTOS_LIBRARY

Optional argument(s)

DEST

Required argument