OSXPhotos Command Line Interface (CLI)#

osxphotos#

OSXPhotos: the multi-tool for your Photos library.

To get help on a specific command, use “osxphotos COMMAND –help” or “osxphotos help COMMAND”; for example, “osxphotos help export”.

To search help for a specific topic within a command, run “osxphotos help COMMAND TOPIC”; for example, “osxphotos help export keyword” to get help related to keywords when using the export command.

To see the full documentation in your browser, run “osxphotos docs”.

Some advanced commands are hidden by default. To see all commands, run “OSXPHOTOS_SHOW_HIDDEN=1 osxphotos help”. Some commands also have hidden options. These can be seen by running “OSXPHOTOS_SHOW_HIDDEN=1 osxphotos help COMMAND”.

osxphotos [OPTIONS] COMMAND [ARGS]...

Options

-v, --version#

Show the version and exit.

about#

Print information about osxphotos including license.

osxphotos about [OPTIONS]

add-locations#

Add missing location data to photos in Photos.app using nearest neighbor.

This command will search for photos that are missing location data and look for the nearest neighbor photo within a given window of time that contains location information. If a photo is found within the window of time, the location of the nearest neighbor will be used to update the location of the photo.

For example, if you took pictures with your iPhone and also with a camera that doesn’t have location information, you can use this command to add location information to the photos taken with the camera from those taken with the iPhone.

If you have many photos with missing location information but no nearest neighbor within the window of time, you could add location information to some photos manually then run this command again to add location information to the remaining photos.

You can specify a subset of photos to update using the query options. For example, –selected to update only the selected photos, –added-after 2020-01-01 to update only photos added after Jan 1, 2020, etc.

Example:

Add location data to all photos with missing location data within a ±2 hour window:

osxphotos add-locations –window “2 hr” –verbose

The add-locations command assumes that photos already have the correct date and time. If you have photos that are missing both location data and date/time information, you can use osxphotos timewarp to add date/time information to the photos and then use osxphotos add-locations to add location information. See osxphotos help timewarp for more information.

osxphotos add-locations [OPTIONS]

Options

-w, --window <window>#

Window of time to search for nearest neighbor; searches +/- window of time. Default is 1 hour. Format is one of ‘HH:MM:SS’, ‘D days’, ‘H hours’ (or hr), ‘M minutes’ (or min), ‘S seconds’ (or sec), ‘S’ (where S is seconds).

--dry-run#

Don’t actually add location, just print what would be done. Most useful with –verbose.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--keyword <KEYWORD>#

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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

--theme <THEME>#

Specify the color theme to use for 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

albums#

Print out albums found in the Photos library.

osxphotos albums [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

batch-edit#

Batch edit photo metadata such as title, description, keywords, etc. Operates on currently selected photos.

Select one or more photos in Photos then run this command to edit the metadata.

For example:

osxphotos batch-edit
–verbose
–title “California vacation 2023 {created.year}-{created.dd}-{created.mm} {counter:03d}”
–description “{place.name}”
–keyword “Family” –keyword “Travel”

This will set the title to “California vacation 2023 2023-02-20 001”, and so on, the description to the reverse geolocation place name, and add the keywords “Family” and “Travel”.

–title, –description, and –keyword may be any valid template string. See https://rhettbull.github.io/osxphotos/template_help.html or osxphotos docs for more information on the osxphotos template system.

osxphotos batch-edit [OPTIONS]

Options

-t, --title <TITLE_TEMPLATE>#

Set title of photo.

-d, --description <DESCRIPTION_TEMPLATE>#

Set description of photo.

-k, --keyword <KEYWORD_TEMPLATE>#

Add keywords to photo. May be specified multiple times.

-K, --replace-keywords#

When specified with –keyword, replace existing keywords. Default is to add to existing keywords.

-l, --location <LATITUDE LONGITUDE>#

Set location of photo. Must be specified as a pair of numbers with latitude in the range -90 to 90 and longitude in the range -180 to 180.

-a, --album <ALBUM_TEMPLATE>#

Add photo to album ALBUM_TEMPLATE. ALBUM_TEMPLATE is an osxphotos template string. Photos may be added to more than one album by repeating –album. See also, –split-folder. See Template System in help (osxphotos docs) for additional information.

-f, --split-folder <split_folder>#

When used with –album, automatically create hierarchal folders for albums as needed by splitting album name into folders and album. You must specify the character used to split folders and albums. For example, ‘–split-folder “/”’ will split the album name ‘Folder/Album’ into folder ‘Folder’ and album ‘Album’.

--dry-run#

Don’t actually change anything.

-u, --undo#

Restores photo metadata to what it was prior to the last batch edit. May be combined with –dry-run to see what will be undone. Note: –undo cannot undo album changes at this time; photos added to an album with –album will remain in the album after –undo.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--theme <THEME>#

Specify the color theme to use for 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

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify Photos library path. If not provided, osxphotos will attempt to find the library to use in the following order: 1. last opened library, 2. system library, 3. ~/Pictures/Photos Library.photoslibrary

compare#

Compare two Photos libraries to find differences

osxphotos compare [OPTIONS] LIBRARY_A LIBRARY_B

Options

-k, --check#

Check if libraries are different and print out total number of differences. If libraries are different, exits with error code 1, otherwise 0 if they are the same.

-c, --csv#

Output results in CSV (comma delimited) format

-t, --tsv#

Output results in TSV (tab delimited) format

-j, --json#

Output results in JSON format

-o, --output <output>#
-s, --signature <signature>#

Custom template for signature. The signature is used to match photos from one library to another. The default is ‘{photo.original_filename|lower}:{photo.fingerprint}’ which should work well in most cases.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

Arguments

LIBRARY_A#

Required argument

LIBRARY_B#

Required argument

docs#

Open osxphotos documentation in your browser.

osxphotos docs [OPTIONS]

dump#

Print list of all photos & associated info from the Photos library.

NOTE: dump is DEPRECATED and will be removed in a future release. Use osxphotos query instead.

osxphotos dump [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

--deleted-only#

Include only photos from the ‘Recently Deleted’ folder.

--deleted#

Include photos from the ‘Recently Deleted’ folder.

-f, --field <FIELD TEMPLATE>#

Output only specified custom fields. FIELD is the name of the field and TEMPLATE is the template to use as the field value. May be repeated to output multiple fields. For example, to output photo uuid, name, and title: –field uuid “{uuid}” –field name “{original_name}” –field title “{title}”.

--print <TEMPLATE>#

Render TEMPLATE string for each photo queried and print to stdout. TEMPLATE is an osxphotos template string. This may be useful for creating custom reports, etc. If –print TEMPLATE is provided, regular output is suppressed and only the rendered TEMPLATE values are printed. May be repeated to print multiple template strings.

exiftool#

Run exiftool on previously exported files to update metadata.

If you previously exported photos with osxphotos export but did not include the –exiftool option and you now want to update the metadata of the exported files with exiftool, you can use this command to do so.

If you simply re-run the osxphotos export with –update and –exiftool, osxphotos will re-export all photos because it will detect that the previously exported photos do not have the exiftool metadata updates. This command will run exiftool on the previously exported photos to update all metadata then will update the export database so that using –exiftool –update with osxphotos export in the future will work correctly and not unnecessarily re-export photos.

osxphotos exiftool [OPTIONS] EXPORT_DIRECTORY

Options

--db-config#

Load configuration options from the export database to match the last export; If any other command line options are used in conjunction with –db-config, they will override the corresponding values loaded from the export database; see also –load-config.

--load-config <CONFIG_FILE>#

Load options from file as written with –save-config. If any other command line options are used in conjunction with –load-config, they will override the corresponding values in the config file; see also –db-config.

--save-config <CONFIG_FILE>#

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

--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.

--exportdb <exportdb>#

Optional path to export database (if not in the default location in the export directory).

--report <REPORT_FILE>#

Write a report of all files that were exported. The extension of the report filename will be used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). REPORT_FILE may be a template string (see Templating System), for example, –report ‘export_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

--append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--dry-run#

Run in dry-run mode (don’t actually update files), e.g. for use with –update-signatures.

--theme <THEME>#

Specify the color theme to use for 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

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

Arguments

EXPORT_DIRECTORY#

Required argument

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 different option is provided, they are treated as “AND” (e.g. search for photos matching all options). If the same query option is provided multiple times, they are treated as “OR” (e.g. search for photos matching any of the options). If no query options are provided, all photos will be exported.

For example, adding the query options:

–person “John Doe” –person “Jane Doe” –keyword “vacation”

will export all photos with either person of (“John Doe” OR “Jane Doe”) AND keyword of “vacation”

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] DEST

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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; may be specified multiple times for more 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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

--deleted-only#

Include only photos from the ‘Recently Deleted’ folder.

--deleted#

Include 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.

--update-errors#

Update files that were previously exported but produced errors during export. For example, if a file produced an error with –exiftool due to bad metadata, this option will re-export the file and attempt to write the metadata again when used with –exiftool and –update. Without –update-errors, photos that were successfully exported but generated an error or warning during export will not be re-attempted if metadata has not changed. Must be used with –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.

--limit <LIMIT>#

Export at most LIMIT photos. Useful for testing. May be used with –update to export incrementally.

--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

--fix-orientation#

Automatically fix image orientation in exported photos to match orientation in Photos database. Requires exiftool be installed and in the path. This is useful mainly for iPhoto libraries. When an image is rotated in iPhoto, the image orientation is not actually changed, instead the image is tagged with an orientation value in the iPhoto database. This means that when the image is exported, the orientation may not be correct. This option will read the EXIF orientation data and fix the image’s orientation if necessary. If used with Photos libraries, this option will result in the original image also being adjusted upon export.

--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.

--export-aae#

Also export an adjustments file detailing edits made to the original. The resulting file is named photoname.AAE. Note that to import these files back to Photos succesfully, you also need to export the edited photo and match the filename format Photos.app expects: –filename ‘IMG_{edited_version?E,}{id:04d}’ –edited-suffix ‘’

--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’.

--sidecar-template <MAKO_TEMPLATE_FILE SIDECAR_FILENAME_TEMPLATE OPTIONS>#

Create a custom sidecar file for each photo exported with user provided Mako template (MAKO_TEMPLATE_FILE). MAKO_TEMPLATE_FILE must be a valid Mako template (see https://www.makotemplates.org/). The template will passed the following variables: photo (PhotoInfo object for the photo being exported), sidecar_path (pathlib.Path object for the path to the sidecar being written), and photo_path (pathlib.Path object for the path to the exported photo. SIDECAR_FILENAME_TEMPLATE must be a valid template string (see Templating System in help) which will be rendered to generate the filename of the sidecar file. The {filepath} template variable may be used in the SIDECAR_FILENAME_TEMPLATE to refer to the filename of the photo being exported. OPTIONS is a comma-separated list of strings providing additional options to the template. Valid options are: write_skipped, strip_whitespace, strip_lines, skip_zero, catch_errors, none. write_skipped will cause the sidecar file to be written even if the photo is skipped during export. If write_skipped is not passed as an option, the sidecar file will not be written if the photo is skipped during export. strip_whitespace and strip_lines indicate whether or not to strip whitespace and blank lines, respectively, from the resulting sidecar file. skip_zero causes the sidecar file to be skipped if the rendered template is zero-length. catch_errors causes errors in the template to be caught and logged but not raised. Without catch_errors, osxphotos will abort the export if an error occurs in the template. For example, to create a sidecar file with extension .xmp using a template file named ‘sidecar.mako’ and write a sidecar for skipped photos and strip blank lines but not whitespace: –sidecar-template sidecar.mako ‘{filepath}.xmp’ write_skipped,strip_lines. To do the same but to drop the photo extension from the sidecar filename: –sidecar-template sidecar.mako ‘{filepath.parent}/{filepath.stem}.xmp’ write_skipped,strip_lines. If you are not passing any options, you must pass ‘none’ as the last argument to –sidecar-template: –sidecar-template sidecar.mako ‘{filepath}.xmp’ none. For an example Mako file see https://raw.githubusercontent.com/RhetTbull/osxphotos/main/examples/custom_sidecar.mako

--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’.

--favorite-rating#

When used with –exiftool or –sidecar, set XMP:Rating=5 for photos marked as Favorite and XMP:Rating=0 for non-Favorites. If not specified, XMP:Rating is not set.

--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’, ‘participants’, ‘projects’, ‘starrating’, ‘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 <REPORT_FILE>#

Write a report of all files that were exported. The extension of the report filename will be used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). REPORT_FILE may be a template string (see Templating System), for example, –report ‘export_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

--append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

--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. To prevent files not generated by osxphotos from being deleted, you may specify one or more rules in a file named .osxphotos_keep in the export directory. This file uses the same format as a .gitignore file and should contain one rule per line; lines starting with a # will be ignored. Reference https://git-scm.com/docs/gitignore#_pattern_format for details. In addition to the standard .gitignore rules, the rules may also be the absolute path to a file or directory. For example if export destination is /Volumes/Photos and you want to keep all .txt files, in the top level of the export directory, you can specify /*.txt” in the .osxphotos_keep file. If you want to keep all .txt files in the export directory and all subdirectories, you can specify **/*.txt. If present, the .osxphotos_keep file will be read after the export is completed and any rules found in the file will be added to the list of rules to keep. See also –keep.

--keep <KEEP_RULE>#

When used with –cleanup, prevents file or directory matching KEEP_RULE from being deleted when cleanup is run. Use this if there are files in the export directory that you don’t want to be deleted when –cleanup is run. KEEP_RULE follows the same format rules a .gitignore file. Reference https://git-scm.com/docs/gitignore#_pattern_format for details. In addition to the standard .gitignore rules, KEEP_RULE may also be the absolute path to a file or directory. For example if export destination is /Volumes/Photos and you want to keep all .txt files, in the top level of the export directory, you can specify –keep “/*.txt”. If you want to keep all .txt files in the export directory and all subdirectories, you can specify –keep “**/*.txt”. If wild card is used, KEEP_RULE must be enclosed in quotes to prevent the shell from expanding the wildcard. –keep may be repeated to keep additional files/directories. Rules may also be included in a file named .osxphotos_keep in the export directory. If present, this file will be read after the export is completed and any rules found in the file will be added to the list of rules to keep. This file uses the same format as a .gitignore file and should contain one rule per line; lines starting with a # will be ignored.

--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.

--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.

--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.

--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 also –post-command-error and –post-function.See Post Command below.

--post-command-error <ACTION>#

Specify either continue or break for ACTION to control behavior when a post-command fails. If continue, osxphotos will log the error and continue processing. If break, osxphotos will stop processing any additional –post-command commands for the current photo but will continue with the export. Without –post-command-error, osxphotos will abort the export if a post-command encounters an error.

Options:

continue | break

--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. You may also specify a post function using a URL in format –post-function ‘https://path/to/module.py::function’ 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; will improve performance when exporting over a network or slow disk. See also –checkpoint.

--checkpoint <NUMBER_OF_PHOTOS>#

When used with –ramdb, periodically save the export database back to disk after processing NUMBER_OF_PHOTOS. When using –ramdb, the export database will be automatically saved if there is a crash or interrupt thus you do not generally need to specify –checkpoint and doing so may slow down the export if your export database is large. This is an advanced feature for those who need to fine-tune the behavior of osxphotos.

-F, --ignore-exportdb#

If exporting to a directory that already contains an export database and –update is not specified, do not prompt to continue but instead continue the export. Normally, if you export to a directory that already contains an export database and do not specify –update, osxphotos will prompt you to continue. This is because you may be inadvertently merging two export sets. Use –ignore-exportdb to skip this prompt and continue the export. The resulting export database will contain the combined state of both export sets. Short option is ‘-F’ (mnemonic: force export). See also –update.

--no-exportdb#

Do not create an export database. This exports all photos in the export set but does not save any state information in the osxphotos export database. If you use –no-exportdb, you will not be able to use –update on subsequent exports. It is recommended that you do not use this option unless you are certain you understand the implications.

--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.

--alt-copy#

Use alternate copy method that may be more reliable for some network attached storage (NAS) devices. Use –alt-copy if you experience problems exporting to a NAS device or SMB volume. Unlike the default copy method, –alt-copy does not support copy-on-write on APFS volumes nor does it preserve filesystem metadata.

--alt-db <PATH>#

Specify alternate path to Photos library database. This is an advanced feature you probably don’t need. This may be useful when exporting from a library on a very slow external disk. In this case, you could copy the /database folder from the Photos library to the internal diskand use –alt-db to specify the path to the database file on the internal disk. then use –library to specify the path to the Photos library root on the external disk. For example: –library /Volumes/ExternalDisk/Photos.photoslibrary –alt-db /path/to/database/Photos.sqlite

--load-config <CONFIG_FILE>#

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>#

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.

--print <TEMPLATE>#

Render TEMPLATE string for each photo being exported and print to stdout. TEMPLATE is an osxphotos template string. This may be useful for creating custom reports, etc. TEMPLATE will be printed after the photo is exported or skipped. May be repeated to print multiple template strings.

--theme <THEME>#

Specify the color theme to use for 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

DEST#

Required argument

exportdb#

Utilities for working with the osxphotos export database

osxphotos exportdb [OPTIONS] EXPORT_DATABASE

Options

--version#

Print export database version and exit.

--vacuum#

Run VACUUM to defragment the database.

--create <VERSION>#

Create a new export database with VERSION.

--check-signatures#

Check signatures for all exported photos in the database to find signatures that don’t match.

--update-signatures#

Update signatures for all exported photos in the database to match on-disk signatures.

--touch-file#

Touch files on disk to match created date in Photos library and update export database signatures

--last-run#

Show last run osxphotos commands used with this database.

--save-config <CONFIG_FILE>#

Save last run configuration to TOML file for use by –load-config.

--info <FILE_PATH>#

Print information about FILE_PATH contained in the database.

--errors#

Print list of files that had warnings/errors on export (from all runs).

--last-errors#

Print list of files that had warnings/errors on last export run.

--uuid-files <UUID>#

List exported files associated with UUID.

--uuid-info <UUID>#

Print information about UUID contained in the database.

--history <FILE_PATH_OR_UUID>#

Print history of FILE_PATH_OR_UUID contained in the database.

--delete-uuid <UUID>#

Delete all data associated with UUID from the database.

--delete-file <FILE_PATH>#

Delete all data associated with FILE_PATH from the database; does not delete the actual exported file if it exists, only the data in the database.

--report <REPORT_FILE RUN_ID>#

Generate an export report as osxphotos export … –report REPORT_FILE would have done. This allows you to re-create an export report if you didn’t use the –report option when running osxphotos export. The extension of the report file is used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). RUN_ID may be any integer from -10 to 0 specifying which run to use. For example, –report report.csv 0 will generate a CSV report for the last run and –report report.json -1 will generate a JSON report for the second-to-last run (one run prior to last run). REPORT_FILE may be a template string (see Templating System), for example, –report ‘export_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

--upgrade#

Upgrade (if needed) export database to current version.

--check#

Check export database for errors.

--repair#

Repair export database. This may be useful if the export database is corrupted and osxphotos reports ‘database disk image is malformed’ errors.

--sql <SQL_STATEMENT>#

Execute SQL_STATEMENT against export database and print results.

--migrate-photos-library <PHOTOS_LIBRARY>#

Migrate the export database to use the specified Photos library. Use this if you have moved your Photos library to a new location or computer and want to keep using the same export database. This will update the UUIDs in the export database to match the new Photos library.

--export-dir <export_dir>#

Optional path to export directory (if not parent of export database).

--append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--theme <THEME>#

Specify the color theme to use for 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

--dry-run#

Run in dry-run mode (don’t actually update files); for example, use with –update-signatures or –migrate-photos-library.

Arguments

EXPORT_DATABASE#

Required argument

help#

Print help; for help on commands: help <command>.

osxphotos help [OPTIONS] [TOPIC] [SUBTOPIC]

Arguments

TOPIC#

Optional argument

SUBTOPIC#

Optional argument

import#

Import photos and videos into Photos. Photos will be imported into the most recently opened Photos library.

Limitations:

  • Photos are imported one at a time thus the “Imports” album in Photos will show

a new import group for each photo imported.

  • Live photos and RAW+JPEG pairs are imported as separate files, not as a single asset.

  • If there’s an edited version of a photo along with the original, they will be imported as separate files, not as a single asset.

osxphotos import [OPTIONS] [FILES]...

Options

-a, --album <ALBUM_TEMPLATE>#

Import photos into album ALBUM_TEMPLATE. ALBUM_TEMPLATE is an osxphotos template string. Photos may be imported into more than one album by repeating –album. See also –skip-dups, –dup-albums, –split-folder, –relative-to. See Template System in help for additional information.

-t, --title <TITLE_TEMPLATE>#

Set title of imported photos to TITLE_TEMPLATE. TITLE_TEMPLATE is a an osxphotos template string. See Template System in help for additional information.

-d, --description <DESCRIPTION_TEMPLATE>#

Set description of imported photos to DESCRIPTION_TEMPLATE. DESCRIPTION_TEMPLATE is a an osxphotos template string. See Template System in help for additional information.

-k, --keyword <KEYWORD_TEMPLATE>#

Set keywords of imported photos to KEYWORD_TEMPLATE. KEYWORD_TEMPLATE is a an osxphotos template string. More than one keyword may be set by repeating –keyword. See Template System in help for additional information.

-m, --merge-keywords#

Merge keywords created by –exiftool, –sidecar, –sidecar-filename, or –keyword with any keywords already associated with the photo. Without –merge-keywords, existing keywords will be overwritten.

-l, --location <LATITUDE LONGITUDE>#

Set location of imported photo to LATITUDE LONGITUDE. Latitude is a number in the range -90.0 to 90.0; positive latitudes are north of the equator, negative latitudes are south of the equator. Longitude is a number in the range -180.0 to 180.0; positive longitudes are east of the Prime Meridian; negative longitudes are west of the Prime Meridian.

-P, --parse-date <DATE_PATTERN>#

Parse date from filename using DATE_PATTERN. If file does not match DATE_PATTERN, the date will be set by Photos using Photo’s default behavior. DATE_PATTERN is a strptime-compatible pattern with extensions as pattern described below. If DATE_PATTERN matches time zone information, the time will be set to the local time in the timezone as the import command does not yet support setting time zone information. For example, if your photos are named ‘IMG_1234_2022_11_23_12_34_56.jpg’ where the date/time is ‘2022-11-23 12:34:56’, you could use the pattern ‘%Y_%m_%d_%H_%M_%S’ or ‘IMG_*_%Y_%m_%d_%H_%M_%S’ to further narrow the pattern to only match files with ‘IMG_xxxx_’ in the name. If the pattern matches only date or only time, the missing information will be set to the default date/time used by Photos when importing the photo. This is either the EXIF date/time if it exists or the file modification date/time. For example, if photos are named ‘IMG_1234_2022_11_23.jpg’ where the date is ‘2022-11-23’, you could use the pattern ‘%Y_%m_%d’ to set the date but the time would be set from the EXIF or the file’s modification time. See also –parse-folder-date, –check-templates.

-F, --parse-folder-date <DATE_PATTERN>#

Parse date from folder name using DATE_PATTERN. If folder does not match DATE_PATTERN, the date will be set by Photos using Photo’s default behavior. DATE_PATTERN is a strptime-compatible pattern with extensions as pattern described below. If DATE_PATTERN matches time zone information, the time will be set to the local time in the timezone as the import command does not yet support setting time zone information. For example, if your photos are in folder ‘2023/12/17/IMG_1234.jpg` where the date is ‘2023-12-17’, you could use the pattern ‘%Y/%m/%d$’ as the DATE_PATTERN. If the pattern matches only date or only time, the missing information will be set to the default date/time used by Photos when importing the photo. This is either the EXIF date/time if it exists or the file modification date/time. See also –parse-folder-date, –check-templates.

-X, --clear-metadata#

Clear any metadata set automatically by Photos upon import. Normally, Photos will set title, description, and keywords from XMP metadata in the imported file. If you specify –clear-metadata, any metadata set by Photos will be cleared after import.

-L, --clear-location#

Clear any location data automatically imported by Photos. Normally, Photos will set location of the photo to the location data found in the metadata in the imported file. If you specify –clear-location, this data will be cleared after import.

-e, --exiftool#

Use third party tool exiftool (https://exiftool.org/) to automatically update metadata (title, description, keywords, location) in imported photos from the imported file’s metadata. See also –sidecar, –sidecar-filename. Note: importing keywords from video files is not currently supported.

-p, --exiftool-path <EXIFTOOL_PATH>#

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

-s, --sidecar#

Use sidecar files to import metadata (title, description, keywords, location). Sidecar files must be in the same directory as the imported file and have the same name. For example, if image is named img_1234.jpg, sidecar must be named one of: img_1234.xmp, img_1234.json, img_1234.jpg.xmp, img_1234.jpg.json. Supported sidecar formats are XMP and JSON (as generated by exiftool). If both JSON and XMP sidecars are found, the JSON sidecar will be used. If sidecar format is XMP, exiftool must be installed as it is used to read the XMP files. See also –sidecar-filename if you need control over the sidecar name. See also –sidecar-ignore-date. Note: –sidecar and –sidecar-filename are mutually exclusive.

-T, --sidecar-filename <TEMPLATE>#

Use sidecar files to import metadata (title, description, keywords, location). The TEMPLATE is an osxphotos template string that is rendered to produce the sidecar filename. The path to the current file is available as {filepath}. Thus if file is named ‘IMG_1234.jpg’ and sidecar is named ‘IMG_1234.xmp’, you would use the template ‘{filepath.parent}/{filepath.stem}.xmp’. If the sidecar name was ‘IMG_1234.jpg.xmp’, you would use the template ‘{filepath}.xmp’. If the sidecar format is XMP, exiftool must be installed as it is used to read the XMP files. See Template System in help for additional information. See also –sidecar-ignore-date. Note: –sidecar and –sidecar-filename are mutually exclusive.

-i, --sidecar-ignore-date#

Do not use date in sidecar to set photo date/time. Setting the timezone from sidecar files is not currently supported so when using –sidecar or –sidecar-filename, the date/time found in the sidecar will be converted to the local timezone and that value will be used to set the photo date/time. If your photos have correct timezone information in the embedded metadata you can use –sidecar-ignore-date to ignore the date/time in the sidecar and use the date/time from the file (which will be read by Photos on import).

-r, --relative-to <RELATIVE_TO_PATH>#

If set, the ‘{filepath}’ template will be computed relative to RELATIVE_TO_PATH. For example, if path to import is ‘/Volumes/photos/import/album/img_1234.jpg’ then ‘{filepath}’ will be this same value. If you set ‘–relative-to /Volumes/photos/import’ then ‘{filepath}’ will be set to ‘album/img_1234.jpg’

-D, --dup-check#

Use Photos’ built-in duplicate checkign to check for duplicates on import. Using –dup-check will cause Photos to display a dialog box for each duplicate photo found, requesting confirmation to import the duplicate. See also –skip-dups.

-S, --skip-dups#

Skip duplicate photos on import; osxphotos will not import any photos that appear to be duplicates. Unlike –dup-check, this does not use Photos’ built in duplicate checking feature and does not display a dialog box for each duplicate found. See also –dup-check and –dup-albums.

-A, --dup-albums#

If used with –skip-dups, the matching duplicate already in the Photos library will be added to any albums the current file would have been added to had it not been skipped. This is useful if you have duplicate photos in separate folders and want to avoid duplicates in Photos but keep the photos organized in albums that match the folder structure. Must be used with –skip-dups and –album. See also –skip-dups.

-f, --split-folder <split_folder>#

Automatically create hierarchal folders for albums as needed by splitting album name into folders and album. You must specify the character used to split folders and albums. For example, ‘–split-folder “/”’ will split the album name ‘Folder/Album’ into folder ‘Folder’ and album ‘Album’.

-w, --walk#

Recursively walk through directories.

-g, --glob <GLOB>#

Only import files matching GLOB. GLOB is a Unix shell-style glob pattern, for example: ‘–glob “*.jpg”’. GLOB may be repeated to import multiple patterns.

-c, --check#

Check which FILES have been previously imported but do not actually import anything. Prints a report showing which files have been imported (and when they were added) and which files have not been imported. See also, –check-not.

-C, --check-not#

Check which FILES have not been previously imported but do not actually import anything. Prints the path to each file that has not been previously imported. See also, –check.

-n, --dry-run#

Dry run; do not actually import. Useful with –verbose to see what would be imported.

-o, --report <REPORT_FILE>#

Write a report of all files that were imported. The extension of the report filename will be used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). REPORT_FILE may be a template string (see Template System), for example, –report ‘export_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

-R, --resume#

Resume previous import. Note: data on each imported file is kept in a database in ‘/Users/rhet/.local/share/osxphotos/osxphotos_import.db’. This data can be used to resume a previous import if there was an error or the import was cancelled.

-O, --append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

-N, --no-progress#

Do not display progress bar during import.

--check-templates#

Don’t actually import anything; renders template strings and date patterns so you can verify they are correct.

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

Run python function after importing file.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 a reference to the photo object and the path to the file that was imported. You can run more than one function by repeating the ‘–post-function’ option with different arguments. You may also specify a post function using a URL in format –post-function ‘https://path/to/module.py::function’ See Post Function below.

--library <LIBRARY_PATH>#

Path to the Photos library you are importing into. This is not usually needed. You will only need to specify this if osxphotos cannot determine the path to the library in which case osxphotos will tell you to use the –library option when you run the import command.

--theme <THEME>#

Specify the color theme to use for 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

FILES#

Optional argument(s)

info#

Print out descriptive info of the Photos library database.

osxphotos info [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

inspect#

Interactively inspect photos selected in Photos.

Open Photos then run osxphotos inspect in the terminal. As you select a photo in Photos, inspect will display metadata about the photo. Press Ctrl+C to exit when done. Works best with a modern terminal like iTerm2 or Kitty.

osxphotos inspect [OPTIONS]

Options

-t, --detect-text#

Detect text in photos

-T, --template <TEMPLATE>#

Template string to render for each photo using template preview mode. Useful for testing templates for export; may be repeated to test multiple templates. If –template/-T is used, other inspection data will not be displayed.

--theme <THEME>#

Specify the color theme to use for 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

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

--beta#

Include beta properties in output

install#

Install Python packages into the same environment as osxphotos

osxphotos install [OPTIONS] [PACKAGES]...

Options

-U, --upgrade#

Upgrade packages to latest version.

-r <FILE>#

Install from requirements file FILE.

Arguments

PACKAGES#

Optional argument(s)

keywords#

Print out keywords found in the Photos library.

osxphotos keywords [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

labels#

Print out image classification labels found in the Photos library.

osxphotos labels [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

list#

Print list of Photos libraries found on the system.

osxphotos list [OPTIONS]

Options

--json#

Print output in JSON format.

orphans#

Find orphaned photos in a Photos library

osxphotos orphans [OPTIONS]

Options

--export <EXPORT_PATH>#

Export orphans to directory EXPORT_PATH. If –export not specified, orphans are listed but not exported.

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--theme <THEME>#

Specify the color theme to use for 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

persons#

Print out persons (faces) found in the Photos library.

osxphotos persons [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

places#

Print out places found in the Photos library.

osxphotos places [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

push-exif#

Write photo metadata to original files in the Photos library

METADATA must be one or more of the following, separated by commas: all keywords location faces persons datetime title description

  • all: all metadata

  • keywords: keywords/tags (e.g. IPTC:Keywords, etc.)

  • location: location information (e.g. EXIF:GPSLatitude, EXIF:GPSLongitude, etc.)

  • faces: face region information (e.g. XMP:RegionName, etc.)

  • persons: person in image information (e.g. XMP:PersonInImage, etc.)

  • datetime: date/time information (e.g. EXIF:DateTimeOriginal, etc.)

  • title: title information (e.g. XMP:Title, etc.)

  • description: description information (e.g. XMP:Description, etc.)

For example to push (write) keywords and faces information to the original files: osxphotos push-exif keywords,faces

To write all metadata to the original files: osxphotos push-exif all

This command will use exiftool (which must be installed separately) to write metadata to the original files in the Photos library.

The metadata in Photos database including keywords, persons/faces, titles, etc. will be written to the original files. This is useful if you want to ensure that the original file retains the metadata in the Photos database.

You may use options to control which metadata is written to the original files. Metadata may also optionally be written to edited photos/videos using –push-edited.

WARNING: This command will modify the original files in the Photos library. It is recommended that you make a backup of your Photos library before running this command. It is also not recommended that you run this command on a library that is managed by iCloud Photos. Changes to files in an iCloud library may not be synced back to iCloud. This is most useful for libraries that are not managed by iCloud Photos or for libraries using referenced files.

The metadata is stored in a SQLite database in your home directory and will be used to automatically update or skip files as needed on subsequent runs of this command.

Several options such as –keyword-template allow you to specify a template string to use to generate keywords. See OSXPhotos Template System in osxphotos docs for more details as well as osxphotos template for an interactive template editor.

If you want to compare metadata between Photos and the original files without writing metadata, use the –compare option. This will print a report of any differences between the metadata in Photos and the original files but will not modify any files. You may also use the –dry-run option to see what would be done without actually writing any files. This is useful for testing the command before actually writing metadata to files.

push-exif cannot be used on photos in classic shared albums. These photos will be automatically skipped.

osxphotos push-exif [OPTIONS] METADATA

Options

--push-edited#

Push EXIF data to edited photos in addition to originals.

--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. 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 from Photos.

--exiftool-merge-persons#

Merge any persons found in the original file with persons from Photos.

--favorite-rating#

Set XMP:Rating=5 for photos marked as Favorite and XMP:Rating=0 for non-Favorites. If not specified, XMP:Rating is not set.

--ignore-date-modified#

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 writing metadata.

--album-keyword#

Use album name as keyword/tag when writing metadata.

--keyword-template <TEMPLATE>#

Specify a template string to use as keyword. For example, if you wanted to add the full path to the folder and album photo is contained in as a keyword when writing metadata, 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 OSXPhotos Template System in osxphotos docs.

--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>#

Specify a template string to use as description. For example, if you wanted to append ‘updated with osxphotos on [today’s date]’ to the description, you could specify –description-template “{descr} updated with osxphotos on {today.date}” See OSXPhotos Template System in osxphotos docs for more details.

--report <REPORT_FILE>#

Write a report of all files that were processed. The extension of the report filename will be used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). REPORT_FILE may be a template string (see OSXPhotos Template System), for example, –report ‘push_exif_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

--append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

--compare#

Compare metadata only; do not push (write) metadata.

--dry-run#

Dry run mode; show what would be done but do not actually write to any files.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--theme <THEME>#

Specify the color theme to use for 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

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

--keyword <KEYWORD>#

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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

Arguments

METADATA#

Required argument

query#

Query the Photos database using 1 or more search options; if more than one different option is provided, they are treated as “AND” (e.g. search for photos matching all options). If the same query option is provided multiple times, they are treated as “OR” (e.g. search for photos matching any of the options).

For example:

osxphotos query –person “John Doe” –person “Jane Doe” –keyword “vacation”

will return all photos with either person of (“John Doe” OR “Jane Doe”) AND keyword of “vacation”

If not query options are provided, all photos in the library will be returned.

osxphotos query [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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.

--count#

Print count of photos matching query and exit.

--keyword <KEYWORD>#

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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

--deleted-only#

Include only photos from the ‘Recently Deleted’ folder.

--deleted#

Include photos from the ‘Recently Deleted’ folder.

--add-to-album <ALBUM>#

Add all photos from query to album ALBUM in Photos. Album ALBUM will be created if it doesn’t exist. All photos in the query results will be added to this album. This only works if the Photos library being queried is the last-opened (default) library in Photos.

--quiet#

Quiet output; doesn’t actually print query results. Useful with –print and –add-to-album if you don’t want to see the actual query results.

-f, --field <FIELD TEMPLATE>#

Output only specified custom fields. FIELD is the name of the field and TEMPLATE is the template to use as the field value. May be repeated to output multiple fields. For example, to output photo uuid, name, and title: –field uuid “{uuid}” –field name “{original_name}” –field title “{title}”.

--print <TEMPLATE>#

Render TEMPLATE string for each photo queried and print to stdout. TEMPLATE is an osxphotos template string. This may be useful for creating custom reports, etc. Most useful with –quiet. May be repeated to print multiple template strings.

--mute#

Mute status output while loading Photos library.

repl#

Run interactive osxphotos REPL shell (useful for debugging, prototyping, and inspecting your Photos library)

osxphotos repl [OPTIONS]

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

--emacs#

Launch REPL with Emacs keybindings (default is vi bindings)

--keyword <KEYWORD>#

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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

--deleted-only#

Include only photos from the ‘Recently Deleted’ folder.

--deleted#

Include photos from the ‘Recently Deleted’ folder.

run#

Run a python file using same environment as osxphotos. Any args are made available to the python file.

The python file may be a path on disk, osxphotos run /path/to/file.py or a URL to a python file, for example,

osxphotos run https://raw.githubusercontent.com/RhetTbull/osxphotos/main/examples/count_photos.py

osxphotos run [OPTIONS] PYTHON_FILE ARGS

Options

-h, --help#

Show this message and exit.

Arguments

PYTHON_FILE#

Required argument

ARGS#

Optional argument(s)

show#

Show photo, album, or folder in Photos from UUID_OR_NAME

Examples:

osxphotos show 12345678-1234-1234-1234-123456789012

osxphotos show “My Album”

osxphotos show “My Folder”

osxphotos show IMG_1234.JPG

show can also be used to show a photo exported with osxphotos export:

osxphotos show /path/to/exported/photo.jpg

In this case, the UUID_OR_NAME is the path to the exported photo and osxphotos will attempt to find the export database to match the photo to the original in Photos. If your export database is not in the default location in the root of the export directory, this will not work.

Notes:

This command requires Photos library version 5 or higher. Currently this command cannot be used to show subfolders in Photos.

osxphotos show [OPTIONS] UUID_OR_NAME

Options

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

Arguments

UUID_OR_NAME#

Required argument

sync#

Sync metadata and albums between Photos libraries.

Use sync to update metadata in a local Photos library to match metadata in another Photos library. The sync command works by finding identical photos in the local library and the import source and then updating the metadata in the local library to match the metadata in the import source. Photos are considered identical if their original filename and fingerprint match.

The import source can be a Photos library or a metadata export file created with the –export option.

The sync command can be useful if you have imported the same photos to multiple Photos libraries and want to keep the metadata in all libraries in sync.

Metadata can be overwritten (–set) or merged (–merge) with the metadata in the import source. You may specify specific metadata to sync or sync all metadata. See –set and –merge for more details.

The sync command can be used to sync metadata between an iPhone or iPad and a Mac, for example, in the case where you do not use iCloud but manually import photos from your iPhone or iPad to your Mac. To do this, you’ll first need to copy the Photos database from the iPhone or iPad to your Mac. This can be done by connecting your iPhone or iPad to your Mac using a USB cable and then copying the Photos database from the iPhone using a third-party tool such as iMazing (https://imazing.com/). You can then use the sync command and set the import source to the Photos database you copied from the iPhone or iPad.

The sync command can also be used to sync metadata between users using iCloud Shared Photo Library. NOTE: This use case has not yet been tested. If you use iCloud Shared Photo Library and would like to help test this use case, please connect with me on GitHub: https://github.com/RhetTbull/osxphotos/issues/887

You can run the –export and –import commands together. In this case, the import will be run first and then the export will be run.

For example, if you want to sync two Photos libraries between users or two different computers, you can export the metadata to a shared folder.

On the first computer, run:

osxphotos sync –export /path/to/export/folder/computer1.db –merge all –import /path/to/export/folder/computer2.db

On the second computer, run:

osxphotos sync –export /path/to/export/folder/computer2.db –merge all –import /path/to/export/folder/computer1.db

osxphotos sync [OPTIONS]

Options

-e, --export <EXPORT_FILE>#

Export metadata to file EXPORT_FILE for later use with –import. The export file will be a SQLite database; it is recommended to use the .db extension though this is not required.

-i, --import <IMPORT_PATH>#

Import metadata from file IMPORT_PATH. IMPORT_PATH can a Photos library, a Photos database, or a metadata export file created with –export.

-s, --set <METADATA>#

When used with –import, set metadata in local Photos library to match import data. Multiple metadata properties can be specified by repeating the –set option or by using a comma-separated list. METADATA can be one of: all, keywords, albums, title, description, favorite. For example, to set keywords and favorite, use –set keywords –set favorite or –set keywords,favorite. If –set all is specified, all metadata will be set. Note that using –set overwrites any existing metadata in the local Photos library. For example, if a photo is marked as favorite in the local library but not in the import source, –set favorite will clear the favorite status in the local library. The exception to this is that –set albums will not remove the photo from any existing albums in the local library but will add the photo to any new albums specified in the import source.See also –merge.

-m, --merge <METADATA>#

When used with –import, merge metadata in local Photos library with import data. Multiple metadata properties can be specified by repeating the –merge option or by using a comma-separated list. METADATA can be one of: all, keywords, albums, title, description, favorite. For example, to merge keywords and favorite, use –merge keywords –merge favorite or –merge keywords,favorite. If –merge all is specified, all metadata will be merged. Note that using –merge does not overwrite any existing metadata in the local Photos library. For example, if a photo is marked as favorite in the local library but not in the import source, –merge favorite will not change the favorite status in the local library. See also –set.

-U, --unmatched#

When used with –import, print out a list of photos in the import source that were not matched against the local library. Also prints out a list of photos in the local library that were not matched against the import source.

-R, --report <REPORT_FILE>#

Write a report of all photos that were processed with –import. The extension of the report filename will be used to determine the format. Valid extensions are: .csv (CSV file), .json (JSON), .db and .sqlite (SQLite database). REPORT_FILE may be a an osxphotos template string, for example, –report ‘update_{today.date}.csv’ will write a CSV report file named with today’s date. See also –append.

-A, --append#

If used with –report, add data to existing report file instead of overwriting it. See also –report.

--dry-run#

Dry run; when used with –import, don’t actually update metadata.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

--keyword <KEYWORD>#

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

--no-keyword#

Search for photos with no 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. If FILE is ‘-’, read UUIDs from stdin.

--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.

--not-edited#

Search for photos that have not 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.

--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 <DATE>#

Search for items created on or after 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 <DATE>#

Search for items created before 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 <TIME>#

Search for items created on or after TIME of day, e.g. 12:00, or 12:00:00.

--to-time <to_time>#

Search for items created before 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.

--added-before <DATE>#

Search for items added to the library before a specific date/time, e.g. –added-before e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-after <DATE>#

Search for items added to the library on or after a specific date/time, e.g. –added-after e.g. 2000-01-12T12:00:00, 2001-01-12T12:00:00-07:00, or 2000-12-31 (ISO 8601 with/without timezone).

--added-in-last <TIME_DELTA>#

Search for items added to the library in the last TIME_DELTA, where TIME_DELTA is a string like ‘12 hrs’, ‘1 day’, ‘1d’, ‘1 week’, ‘2weeks’, ‘1 month’, ‘1 year’. for example, –added-in-last 7d and –added-in-last ‘1 week’ are equivalent. months are assumed to be 30 days and years are assumed to be 365 days. Common English abbreviations are accepted, e.g. d, day, days or m, min, minutes.

--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).

--not-reference#

Search for photos that are not references, that is, they were copied into the Photos library and are managed by Photos.

--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’.

--missing#

Search for photos missing from disk.

--not-missing#

Search for photos present on disk (e.g. not missing).

--cloudasset#

Search for photos that are part of an iCloud library

--not-cloudasset#

Search for photos that are not part of an iCloud library

--incloud#

Search for photos that are in iCloud (have been synched)

--not-incloud#

Search for photos that are not in iCloud (have not been synched)

--syndicated#

Search for photos that have been shared via syndication (‘Shared with You’ album via Messages, etc.)

--not-syndicated#

Search for photos that have not been shared via syndication (‘Shared with You’ album via Messages, etc.)

--saved-to-library#

Search for syndicated photos that have saved to the library

--not-saved-to-library#

Search for syndicated photos that have not saved to the library

--shared-moment#

Search for photos that are part of a shared moment

--not-shared-moment#

Search for photos that are not part of a shared moment

--shared-library#

Search for photos that are part of a shared library

--not-shared-library#

Search for photos that are not part of a shared library

--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. You may also specify a URL to a python file in the format: –query-function https://path/to/module.py::function See https://github.com/RhetTbull/osxphotos/blob/master/examples/query_function.py for example of a query function.

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

--theme <THEME>#

Specify the color theme to use for 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

template#

Interactively render templates for selected photo.

Launches a REPL (Read-Eval-Print-Loop) to interactively render a template for the selected photo.

Select a photo in Photos then run osxphotos template to start the REPL.

osxphotos template [OPTIONS]

Options

-T, --template <TEMPLATE>#

Template string to render for selected photo. If –template/-T is used, the template will be rendered and printed and the REPL will not be started. Multiple templates may be specified by repeating –template/-T.

--uuid <UUID>#

Use photo with uuid UUID to render template inplace of selected photo.

--library, --db <PHOTOS_LIBRARY_PATH>#

Specify path to Photos library. If not 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

--vi#

Use vi keybindings.

--emacs#

Use emacs keybindings.

theme#

Manage osxphotos color themes.

osxphotos theme [OPTIONS]

Options

--default#

Show default theme.

--list#

List all themes.

--config <THEME>#

Print configuration for THEME (or default theme if not specified).

--preview <THEME>#

Preview THEME (or default theme if not specified).

--edit <THEME>#

Edit THEME (or default theme if not specified).

--clone <THEME NEW_THEME>#

Clone THEME to NEW_THEME.

--delete <THEME>#

Delete THEME.

timewarp#

Adjust date/time/timezone of photos in Apple Photos.

Changes will be applied to all photos currently selected in Photos. timewarp cannot operate on photos selected in a Smart Album; select photos in a regular album or in the ‘All Photos’ view. See Timewarp Overview below for additional information.

osxphotos timewarp [OPTIONS]

Options

-d, --date <DATE>#

Set date for selected photos. Format is ‘YYYY-MM-DD’.

-D, --date-delta <DELTA>#

Adjust date for selected photos by DELTA. Format is one of: ‘±D days’, ‘±W weeks’, ‘±D’ where D is days

-t, --time <TIME>#

Set time for selected photos. Format is one of ‘HH:MM:SS’, ‘HH:MM:SS.fff’, ‘HH:MM’.

-T, --time-delta <DELTA>#

Adjust time for selected photos by DELTA time. Format is one of ‘±HH:MM:SS’, ‘±H hours’ (or hr), ‘±M minutes’ (or min), ‘±S seconds’ (or sec), ‘±S’ (where S is seconds)

-z, --timezone <TIMEZONE>#

Set timezone for selected photos as offset from UTC. Format is one of ‘±HH:MM’, ‘±H:MM’, or ‘±HHMM’. The actual time of the photo is not adjusted which means, somewhat counterintuitively, that the time in the new timezone will be different. For example, if photo has time of 12:00 and timezone of GMT+01:00 and new timezone is specified as ‘–timezone +02:00’ (one hour ahead of current GMT+01:00 timezone), the photo’s new time will be 13:00 GMT+02:00, which is equivalent to the old time of 12:00+01:00. This is the same behavior exhibited by Photos when manually adjusting timezone in the Get Info window. See also –match-time.

--date-added <DATE>#

Set date/time added for selected photos. This changes the date added or imported date in Photos but does not change the date/time/timezone of the photo itself. This is useful for removing photos from the Recents album, for example if you have imported old scanned photos. Format is ‘YYYY-MM-DD’ or ‘YYYY-MM-DD HH:MM:SS’. If time is not included, midnight is assumed.

--date-added-from-photo#

Set date/time added for selected photos to the date/time the photo was taken. This changes the date added or imported date in Photos but does not change the date/time/timezone of the photo itself.

-i, --inspect#

Print out the date/time/timezone for each selected photo without changing any information.

-c, --compare-exif#

Compare the EXIF date/time/timezone for each selected photo to the same data in Photos. Requires the third-party exiftool utility be installed (see https://exiftool.org/). See also –add-to-album.

-p, --push-exif#

Push date/time and timezone for selected photos from Photos to the EXIF metadata in the original file in the Photos library. Requires the third-party exiftool utility be installed (see https://exiftool.org/). Using this option modifies the original file of the image in your Photos library. –push-exif will be executed after any other updates are performed on the photo. Note that if the Photos library is synced to iCloud, the updated EXIF data will not besynced to iCloud and thus exporting the photo on any other device will not show the updated EXIF data. This option is most useful for libraries that are not synced to iCloud. See also –pull-exif.

-P, --pull-exif#

Pull date/time and timezone for selected photos from EXIF metadata in the original file into Photos and update the associated data in Photos to match the EXIF data. –pull-exif will be executed before any other updates are performed on the photo. It is possible for images to have missing EXIF data, for example the date/time could be set but there might be no timezone set in the EXIF metadata. Missing data will be handled thusly: if date/time/timezone are all present in the EXIF data, the photo’s date/time/timezone will be updated. If timezone is missing but date/time is present, only the photo’s date/time will be updated. If date/time is missing but the timezone is present, only the photo’s timezone will be updated unless –use-file-time is set in which case, the photo’s file modification date/time will be used in place of EXIF date/time. If the date is present but the time is missing, the time will be set to 00:00:00. Requires the third-party exiftool utility be installed (see https://exiftool.org/). See also –push-exif.

-M, --parse-date <DATE_PATTERN>#

Parse date from filename using DATE_PATTERN and set photo’s date to match. If file does not match DATE_PATTERN, the date will not be changed. DATE_PATTERN is a strptime-compatible pattern with extensions as pattern described below. If DATE_PATTERN matches time zone information, the photo’s timezone will be set to match. For example, if your photos are named ‘IMG_1234_2022_11_23_12_34_56.jpg’ where the date/time is ‘2022-11-23 12:34:56’, you could use the pattern ‘%Y_%m_%d_%H_%M_%S’ or ‘IMG_*_%Y_%m_%d_%H_%M_%S’ to further narrow the pattern to only match files with ‘IMG_xxxx_’ in the name.

-F, --function <filename.py::function>#

Run python function to determine the date/time/timezone to apply to a photo. Use this in format: –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 being processed and is expected to return a naive datetime.datetime object with time in local time and UTC timezone offset in seconds. You may also specify a function using a URL in format –function ‘https://path/to/module.py::function’ See example function at https://github.com/RhetTbull/osxphotos/blob/master/examples/timewarp_function_example.py

-m, --match-time#

When used with –timezone, adjusts the photo time so that the timestamp in the new timezone matches the timestamp in the old timezone. For example, if photo has time of 12:00 and timezone of GMT+01:00 and new timezone is specified as ‘–timezone +02:00’ (one hour ahead of current GMT+01:00 timezone), the photo’s new time will be 12:00 GMT+02:00. That is, the timezone will have changed but the timestamp of the photo will match the previous timestamp. Use –match-time when the camera’s time was correct for the time the photo was taken but the timezone was missing or wrong and you want to adjust the timezone while preserving the photo’s time. See also –timezone.

-f, --use-file-time#

When used with –pull-exif, the file modification date/time will be used if date/time is missing from the EXIF data.

-a, --add-to-album <ALBUM>#

When used with –compare-exif, adds any photos with date/time/timezone differences between Photos/EXIF to album ALBUM. If ALBUM does not exist, it will be created.

-V, --verbose#

Print verbose output; may be specified multiple times for more verbose output.

--timestamp#

Add time stamp to verbose output

-L, --library <PHOTOS_LIBRARY_PATH>#

Path to Photos library (e.g. ‘~/Pictures/PhotosLibrary.photoslibrary’). This is not likely needed as osxphotos will usually be able to locate the path to the open Photos library. Use –library only if you get an error that the Photos library cannot be located.

-e, --exiftool-path <exiftool_path>#

Optional path to exiftool executable (will look in $PATH if not specified) for those options which require exiftool.

--timestamp#

Add time stamp to verbose output

--theme <THEME>#

Specify the color theme to use for 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

--plain#

Plain text mode. Do not use rich output.

--force#

Bypass confirmation prompt. Use with caution.

tutorial#

Display osxphotos tutorial.

osxphotos tutorial [OPTIONS] [WIDTH]...

Arguments

WIDTH#

Optional argument(s)

uninstall#

Uninstall Python packages from the osxphotos environment

osxphotos uninstall [OPTIONS] PACKAGES...

Options

-y, --yes#

Don’t ask for confirmation.

Arguments

PACKAGES#

Required argument(s)

uuid#

Print out unique IDs (UUID) of photos selected in Photos

Prints outs UUIDs in form suitable for –uuid-from-file and –skip-uuid-from-file

osxphotos uuid [OPTIONS]

Options

-f, --filename#

Include filename of selected photos in output

version#

Check for new version of osxphotos.

osxphotos version [OPTIONS]

Options

--run <COMMAND>#

Run COMMAND if there is a new version of osxphotos available.

Usage: python -m osxphotos [OPTIONS] COMMAND [ARGS]...

  osxphotos: the multi-tool for your Photos library

Options:
  -v, --version  Show the version and exit.
  -h, --help     Show this message and exit.

Commands:
  about          Print information about osxphotos including license.
  add-locations  Add missing location data to photos in Photos.app using...
  albums         Print out albums found in the Photos library.
  batch-edit     Batch edit photo metadata such as title, description,...
  diff           Compare two Photos databases and print out differences
  docs           Open osxphotos documentation in your browser.
  dump           Print list of all photos & associated info from the...
  exiftool       Run exiftool on previously exported files to update...
  export         Export photos from the Photos database.
  exportdb       Utilities for working with the osxphotos export database
  help           Print help; for help on commands: help <command>.
  import         Import photos and videos into Photos.
  info           Print out descriptive info of the Photos library database.
  inspect        Interactively inspect photos selected in Photos.
  install        Install Python packages into the same environment as...
  keywords       Print out keywords found in the Photos library.
  labels         Print out image classification labels found in the...
  list           Print list of Photos libraries found on the system.
  orphans        Find orphaned photos in a Photos library
  persons        Print out persons (faces) found in the Photos library.
  places         Print out places found in the Photos library.
  query          Query the Photos database using 1 or more search...
  repl           Run interactive osxphotos REPL shell (useful for...
  run            Run a python file using same environment as osxphotos.
  show           Show photo, album, or folder in Photos from UUID_OR_NAME
  snap           Create snapshot of Photos database to use with diff command
  sync           Sync metadata and albums between Photos libraries.
  template       Interactively render templates for selected photo.
  theme          Manage osxphotos color themes.
  timewarp       Adjust date/time/timezone of photos in Apple Photos.
  tutorial       Display osxphotos tutorial.
  uninstall      Uninstall Python packages from the osxphotos environment
  uuid           Print out unique IDs (UUID) of photos selected in Photos
  version        Check for new version of osxphotos.