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
+ """
2
17
3
18
import os .path
4
19
import pathlib
10
25
from osxphotos .cli .click_rich_echo import rich_echo as echo
11
26
from osxphotos .cli .click_rich_echo import rich_echo_error
12
27
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
14
29
from osxphotos .exportoptions import ExportOptions
15
30
from osxphotos .fingerprintquery import FingerprintQuery
16
31
from osxphotos .image_file_utils import is_image_file , is_video_file
@@ -34,7 +49,8 @@ def verbose(*args, **kwargs):
34
49
"--drop-ext" ,
35
50
"-d" ,
36
51
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'." ,
38
54
)
39
55
@click .option (
40
56
"--walk" , "-w" , is_flag = True , help = "Walk directories looking for photo/video files."
@@ -64,6 +80,10 @@ def generate_sidecars(
64
80
65
81
Any file paths passed will be matched to photos in Photos. If a matching photo is found,
66
82
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.
67
87
"""
68
88
if not any ([xmp , json_flag , exiftool ]):
69
89
raise click .UsageError (
0 commit comments