diff --git a/README.md b/README.md index 68b410bd..4add8640 100644 --- a/README.md +++ b/README.md @@ -731,6 +731,15 @@ Options: 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 @@ -1864,13 +1873,13 @@ Both the '{shell_quote}' template and the '|shell_quote' template filter are available for this purpose. For example, the following command outputs the full path of newly exported files to file 'new.txt': ---post-command new "echo {filepath.name|shell_quote} >> {shell_quote,{export_dir}/exported.txt}" +--post-command new "echo {filepath|shell_quote} >> {shell_quote,{export_dir}/exported.txt}" -In the above command, the 'shell_quote' filter is used to ensure -'{filepath.name}' is properly quoted and the '{shell_quote}' template ensures -the constructed path of '{exported_dir}/exported.txt' is properly quoted. If -'{filepath.name}' is 'IMG 1234.jpeg' and '{export_dir}' is '/Volumes/Photo -Export', the command thus renders to: +In the above command, the 'shell_quote' filter is used to ensure '{filepath}' is +properly quoted and the '{shell_quote}' template ensures the constructed path of +'{exported_dir}/exported.txt' is properly quoted. If '{filepath}' is 'IMG +1234.jpeg' and '{export_dir}' is '/Volumes/Photo Export', the command thus +renders to: echo 'IMG 1234.jpeg' >> '/Volumes/Photo Export/exported.txt' diff --git a/docs/.buildinfo b/docs/.buildinfo index 07ef3d34..0455eabd 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: a9dc54f8e973cfad202ebe3a13957327 +config: 72fd70158d2f5a08b80c8c23b4740046 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_modules/index.html b/docs/_modules/index.html index e6ae6771..769e9c6b 100644 --- a/docs/_modules/index.html +++ b/docs/_modules/index.html @@ -5,7 +5,7 @@ - Overview: module code — osxphotos 0.43.7 documentation + Overview: module code — osxphotos 0.43.8 documentation diff --git a/docs/_modules/osxphotos/photosdb/photosdb.html b/docs/_modules/osxphotos/photosdb/photosdb.html index b5abaf50..2376efd0 100644 --- a/docs/_modules/osxphotos/photosdb/photosdb.html +++ b/docs/_modules/osxphotos/photosdb/photosdb.html @@ -5,7 +5,7 @@ - osxphotos.photosdb.photosdb — osxphotos 0.43.6 documentation + osxphotos.photosdb.photosdb — osxphotos 0.43.8 documentation @@ -45,6 +45,7 @@ import sys import tempfile from collections import OrderedDict +from collections.abc import Iterable from datetime import datetime, timedelta, timezone from pprint import pformat from typing import List @@ -3503,6 +3504,34 @@ # selection only works if photos selected in main media browser photos = [] + if options.exif: + matching_photos = [] + for p in photos: + if not p.exiftool: + continue + exifdata = p.exiftool.asdict(normalized=True) + exifdata.update(p.exiftool.asdict(tag_groups=False, normalized=True)) + for exiftag, exifvalue in options.exif: + if options.ignore_case: + exifvalue = exifvalue.lower() + exifdata_value = exifdata.get(exiftag.lower(), "") + if isinstance(exifdata_value, str): + exifdata_value = exifdata_value.lower() + elif isinstance(exifdata_value, Iterable): + exifdata_value = [v.lower() for v in exifdata_value] + else: + exifdata_value = str(exifdata_value) + + if exifvalue in exifdata_value: + matching_photos.append(p) + else: + exifdata_value = exifdata.get(exiftag.lower(), "") + if not isinstance(exifdata_value, (str, Iterable)): + exifdata_value = str(exifdata_value) + if exifvalue in exifdata_value: + matching_photos.append(p) + photos = matching_photos + if options.function: for function in options.function: photos = function[0](photos) @@ -3630,7 +3659,7 @@ ©2021, Rhet Turnbull. | - Powered by Sphinx 4.2.0 + Powered by Sphinx 4.3.2 & Alabaster 0.7.12 diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 162dd51c..41a1d9ec 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '0.43.7', + VERSION: '0.43.8', LANGUAGE: 'None', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/cli.html b/docs/cli.html index f01af677..813b8c53 100644 --- a/docs/cli.html +++ b/docs/cli.html @@ -5,7 +5,7 @@ - osxphotos command line interface (CLI) — osxphotos 0.43.7 documentation + osxphotos command line interface (CLI) — osxphotos 0.43.8 documentation @@ -537,6 +537,12 @@ to modify this behavior.

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>
@@ -1506,6 +1512,12 @@ if more than one option is provided, they are treated as “AND”

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>
diff --git a/docs/genindex.html b/docs/genindex.html index 1d0643d9..19b9560d 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -5,7 +5,7 @@ - Index — osxphotos 0.43.7 documentation + Index — osxphotos 0.43.8 documentation @@ -261,6 +261,15 @@ +
  • + --exif <EXIF_TAG VALUE> + +
  • @@ -630,6 +639,8 @@
  • osxphotos-query command line option
  • + + - -