Skip to content

Commit e489233

Browse files
committed
Added sidecars example
1 parent 1cfaeec commit e489233

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

examples/generate_sidecars.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
"""Generate sidecar files for photos previously exported from Photos"""
1+
"""Generate sidecar files for photos previously exported from Photos.
2+
3+
This can be run with:
4+
osxphotos run https://raw.githubusercontent.com/RhetTbull/osxphotos/refs/heads/main/examples/generate_sidecars.py
5+
6+
or
7+
8+
osxphotos run generate_sidecars.py
9+
if you've downloaded the script to your Mac.
10+
11+
Use --help to see help.
12+
13+
This is hacked together using code from `osxphotos import` to allow generation of sidecar files for photos
14+
exported from Photos without the use of `osxphotos export`. If you exported photos using `osxphotos export`,
15+
add options `--update --sidecar xmp` to your export command and re-run it to generate the sidecar files.
16+
"""
217

318
import os.path
419
import pathlib
@@ -10,7 +25,7 @@
1025
from osxphotos.cli.click_rich_echo import rich_echo as echo
1126
from osxphotos.cli.click_rich_echo import rich_echo_error
1227
from osxphotos.cli.rich_progress import rich_progress
13-
from osxphotos.cli.verbose import get_verbose_console, set_verbose_level, verbose_print
28+
from osxphotos.cli.verbose import get_verbose_console, verbose_print
1429
from osxphotos.exportoptions import ExportOptions
1530
from osxphotos.fingerprintquery import FingerprintQuery
1631
from osxphotos.image_file_utils import is_image_file, is_video_file
@@ -34,7 +49,8 @@ def verbose(*args, **kwargs):
3449
"--drop-ext",
3550
"-d",
3651
is_flag=True,
37-
help="Drop image extension when adding sidecar extension.",
52+
help="Drop image extension when adding sidecar extension. "
53+
"For example, sidecar file would be 'IMG_1234.xmp' instead of 'IMG_1234.jpg.xmp'.",
3854
)
3955
@click.option(
4056
"--walk", "-w", is_flag=True, help="Walk directories looking for photo/video files."
@@ -64,6 +80,10 @@ def generate_sidecars(
6480
6581
Any file paths passed will be matched to photos in Photos. If a matching photo is found,
6682
a sidecar file is generated and saved.
83+
84+
At least one of --xmp, --json, --exiftool must be used to generate the appropriate sidecar format.
85+
86+
Use --dry-run to test without actually generating sidecar files.
6787
"""
6888
if not any([xmp, json_flag, exiftool]):
6989
raise click.UsageError(

0 commit comments

Comments
 (0)