forked from RhetTbull/osxphotos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_help.html
766 lines (730 loc) · 63 KB
/
template_help.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<!doctype html>
<html class="no-js" lang="en" data-content_root="./">
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="OSXPhotos Python Package Overview" href="package_overview.html" /><link rel="prev" title="OSXPhotos Command Line Interface (CLI)" href="cli.html" />
<!-- Generated with Sphinx 7.2.5 and Furo 2023.08.19 -->
<title>OSXPhotos Template System - osxphotos 0.63.4 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=a746c00c" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=135e06be" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=36a5483c" />
<style>
body {
--color-code-background: #f8f8f8;
--color-code-foreground: black;
}
@media not print {
body[data-theme="dark"] {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
}
@media (prefers-color-scheme: dark) {
body:not([data-theme="light"]) {
--color-code-background: #202020;
--color-code-foreground: #d0d0d0;
}
}
}
</style></head>
<body>
<script>
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
</script>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="svg-toc" viewBox="0 0 24 24">
<title>Contents</title>
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
</svg>
</symbol>
<symbol id="svg-menu" viewBox="0 0 24 24">
<title>Menu</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</symbol>
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
<title>Expand</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</symbol>
<symbol id="svg-sun" viewBox="0 0 24 24">
<title>Light mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</symbol>
<symbol id="svg-moon" viewBox="0 0 24 24">
<title>Dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
</svg>
</symbol>
<symbol id="svg-sun-half" viewBox="0 0 24 24">
<title>Auto light/dark mode</title>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-shadow">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<circle cx="12" cy="12" r="9" />
<path d="M13 12h5" />
<path d="M13 15h4" />
<path d="M13 18h1" />
<path d="M13 9h4" />
<path d="M13 6h1" />
</svg>
</symbol>
</svg>
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation">
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc">
<label class="overlay sidebar-overlay" for="__navigation">
<div class="visually-hidden">Hide navigation sidebar</div>
</label>
<label class="overlay toc-overlay" for="__toc">
<div class="visually-hidden">Hide table of contents sidebar</div>
</label>
<div class="page">
<header class="mobile-header">
<div class="header-left">
<label class="nav-overlay-icon" for="__navigation">
<div class="visually-hidden">Toggle site navigation sidebar</div>
<i class="icon"><svg><use href="#svg-menu"></use></svg></i>
</label>
</div>
<div class="header-center">
<a href="index.html"><div class="brand">osxphotos 0.63.4 documentation</div></a>
</div>
<div class="header-right">
<div class="theme-toggle-container theme-toggle-header">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-header-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
</header>
<aside class="sidebar-drawer">
<div class="sidebar-container">
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
<span class="sidebar-brand-text">osxphotos 0.63.4 documentation</span>
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
<input type="hidden" name="check_keywords" value="yes">
<input type="hidden" name="area" value="default">
</form>
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="overview.html">OSXPhotos</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">OSXPhotos Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli.html">OSXPhotos Command Line Interface (CLI)</a></li>
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">OSXPhotos Template System</a></li>
<li class="toctree-l1"><a class="reference internal" href="package_overview.html">OSXPhotos Python Package Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="API_README.html">OSXPhotos Python API</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">OSXPhotos Python Reference</a></li>
</ul>
</div>
</div>
</div>
</div>
</aside>
<div class="main">
<div class="content">
<div class="article-container">
<a href="#" class="back-to-top muted-link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
</svg>
<span>Back to top</span>
</a>
<div class="content-icon-container">
<div class="theme-toggle-container theme-toggle-content">
<button class="theme-toggle">
<div class="visually-hidden">Toggle Light / Dark / Auto color theme</div>
<svg class="theme-icon-when-auto"><use href="#svg-sun-half"></use></svg>
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
</button>
</div>
<label class="toc-overlay-icon toc-content-icon" for="__toc">
<div class="visually-hidden">Toggle table of contents sidebar</div>
<i class="icon"><svg><use href="#svg-toc"></use></svg></i>
</label>
</div>
<article role="main">
<section id="osxphotos-template-system">
<h1>OSXPhotos Template System<a class="headerlink" href="#osxphotos-template-system" title="Link to this heading">#</a></h1>
<p>The templating system converts one or template statements, written in osxphotos metadata templating language, to one or more rendered values using information from the photo being processed.</p>
<p>In its simplest form, a template statement has the form: <code class="docutils literal notranslate"><span class="pre">"{template_field}"</span></code>, for example <code class="docutils literal notranslate"><span class="pre">"{title}"</span></code> which would resolve to the title of the photo.</p>
<p>Template statements may contain one or more modifiers. The full syntax is:</p>
<p><code class="docutils literal notranslate"><span class="pre">"pretext{delim+template_field:subfield(field_arg)|filter[find,replace]</span> <span class="pre">conditional?bool_value,default}posttext"</span></code></p>
<p>Template statements are white-space sensitive meaning that white space (spaces, tabs) changes the meaning of the template statement.</p>
<p><code class="docutils literal notranslate"><span class="pre">pretext</span></code> and <code class="docutils literal notranslate"><span class="pre">posttext</span></code> are free form text. For example, if a photo has title “My Photo Title” the template statement <code class="docutils literal notranslate"><span class="pre">"The</span> <span class="pre">title</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">photo</span> <span class="pre">is</span> <span class="pre">{title}"</span></code>, resolves to <code class="docutils literal notranslate"><span class="pre">"The</span> <span class="pre">title</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">photo</span> <span class="pre">is</span> <span class="pre">My</span> <span class="pre">Photo</span> <span class="pre">Title"</span></code>. The <code class="docutils literal notranslate"><span class="pre">pretext</span></code> in this example is <code class="docutils literal notranslate"><span class="pre">"The</span> <span class="pre">title</span> <span class="pre">if</span> <span class="pre">the</span> <span class="pre">photo</span> <span class="pre">is</span> <span class="pre">"</span></code> and the template_field is <code class="docutils literal notranslate"><span class="pre">{title}</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">delim</span></code>: optional delimiter string to use when expanding multi-valued template values in-place</p>
<p><code class="docutils literal notranslate"><span class="pre">+</span></code>: If present before template <code class="docutils literal notranslate"><span class="pre">name</span></code>, expands the template in place. If <code class="docutils literal notranslate"><span class="pre">delim</span></code> not provided, values are joined with no delimiter.</p>
<p>e.g. if Photo keywords are <code class="docutils literal notranslate"><span class="pre">["foo","bar"]</span></code>:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{keyword}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"foo",</span> <span class="pre">"bar"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{,+keyword}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"foo,bar"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{;</span> <span class="pre">+keyword}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"foo;</span> <span class="pre">bar"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{+keyword}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"foobar"</span></code></p></li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">template_field</span></code>: The template field to resolve. See <a class="reference external" href="#template-substitutions">Template Substitutions</a> for full list of template fields.</p>
<p><cite>:subfield</cite>: Some templates have sub-fields, For example, <cite>{exiftool:IPTC:Make}`</cite>; the template_field is``exiftool<code class="docutils literal notranslate"><span class="pre">and</span> <span class="pre">the</span> <span class="pre">sub-field</span> <span class="pre">is</span></code>IPTC:Make`.</p>
<p><code class="docutils literal notranslate"><span class="pre">(field_arg)</span></code>: optional arguments to pass to the field; for example, with <code class="docutils literal notranslate"><span class="pre">{folder_album}</span></code> this is used to pass the path separator used for joining folders and albums when rendering the field (default is “/” for <code class="docutils literal notranslate"><span class="pre">{folder_album}</span></code>).</p>
<p><cite>|filter</cite>: You may optionally append one or more filter commands to the end of the template field using the vertical pipe (‘|’) symbol. Filters may be combined, separated by ‘|’ as in: <code class="docutils literal notranslate"><span class="pre">{keyword|capitalize|parens}</span></code>.</p>
<p>Valid filters are:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">lower</span></code>: Convert value to lower case, e.g. ‘Value’ => ‘value’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">upper</span></code>: Convert value to upper case, e.g. ‘Value’ => ‘VALUE’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">strip</span></code>: Strip whitespace from beginning/end of value, e.g. ‘ Value ‘ => ‘Value’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">titlecase</span></code>: Convert value to title case, e.g. ‘my value’ => ‘My Value’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">capitalize</span></code>: Capitalize first word of value and convert other words to lower case, e.g. ‘MY VALUE’ => ‘My value’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">braces</span></code>: Enclose value in curly braces, e.g. ‘value => ‘{value}’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">parens</span></code>: Enclose value in parentheses, e.g. ‘value’ => ‘(value’)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">brackets</span></code>: Enclose value in brackets, e.g. ‘value’ => ‘[value]’</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">shell_quote</span></code>: Quotes the value for safe usage in the shell, e.g. My file.jpeg => ‘My file.jpeg’; only adds quotes if needed.</p></li>
<li><p><cite>function</cite>: Run custom python function to filter value; use in format ‘function:/path/to/file.py::function_name’. See example at https://github.com/RhetTbull/osxphotos/blob/master/examples/template_filter.py</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">split(x)</span></code>: Split value into a list of values using x as delimiter, e.g. ‘value1;value2’ => [‘value1’, ‘value2’] if used with split(;).</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">autosplit</span></code>: Automatically split delimited string into separate values; will split strings delimited by comma, semicolon, or space, e.g. ‘value1,value2’ => [‘value1’, ‘value2’].</p></li>
<li><p><cite>chop(x)</cite>: Remove x characters off the end of value, e.g. chop(1): ‘Value’ => ‘Valu’; when applied to a list, chops characters from each list value, e.g. chop(1): [‘travel’, ‘beach’]=> [‘trave’, ‘beac’].</p></li>
<li><p><cite>chomp(x)</cite>: Remove x characters from the beginning of value, e.g. chomp(1): [‘Value’] => [‘alue’]; when applied to a list, removes characters from each list value, e.g. chomp(1): [‘travel’, ‘beach’]=> [‘ravel’, ‘each’].</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">sort</span></code>: Sort list of values, e.g. [‘c’, ‘b’, ‘a’] => [‘a’, ‘b’, ‘c’].</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">rsort</span></code>: Sort list of values in reverse order, e.g. [‘a’, ‘b’, ‘c’] => [‘c’, ‘b’, ‘a’].</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">reverse</span></code>: Reverse order of values, e.g. [‘a’, ‘b’, ‘c’] => [‘c’, ‘b’, ‘a’].</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">uniq</span></code>: Remove duplicate values, e.g. [‘a’, ‘b’, ‘c’, ‘b’, ‘a’] => [‘a’, ‘b’, ‘c’].</p></li>
<li><p><cite>join(x)</cite>: Join list of values with delimiter x, e.g. join(,): [‘a’, ‘b’, ‘c’] => ‘a,b,c’; the DELIM option functions similar to join(x) but with DELIM, the join happens before being passed to any filters.May optionally be used without an argument, that is ‘join()’ which joins values together with no delimiter. e.g. join(): [‘a’, ‘b’, ‘c’] => ‘abc’.</p></li>
<li><p><cite>append(x)</cite>: Append x to list of values, e.g. append(d): [‘a’, ‘b’, ‘c’] => [‘a’, ‘b’, ‘c’, ‘d’].</p></li>
<li><p><cite>prepend(x)</cite>: Prepend x to list of values, e.g. prepend(d): [‘a’, ‘b’, ‘c’] => [‘d’, ‘a’, ‘b’, ‘c’].</p></li>
<li><p><cite>appends(x)</cite>: Append s[tring] Append x to each value of list of values, e.g. appends(d): [‘a’, ‘b’, ‘c’] => [‘ad’, ‘bd’, ‘cd’].</p></li>
<li><p><cite>prepends(x)</cite>: Prepend s[tring] x to each value of list of values, e.g. prepends(d): [‘a’, ‘b’, ‘c’] => [‘da’, ‘db’, ‘dc’].</p></li>
<li><p><cite>remove(x)</cite>: Remove x from list of values, e.g. remove(b): [‘a’, ‘b’, ‘c’] => [‘a’, ‘c’].</p></li>
<li><p><cite>slice(start:stop:step)</cite>: Slice list using same semantics as Python’s list slicing, e.g. slice(1:3): [‘a’, ‘b’, ‘c’, ‘d’] => [‘b’, ‘c’]; slice(1:4:2): [‘a’, ‘b’, ‘c’, ‘d’] => [‘b’, ‘d’]; slice(1:): [‘a’, ‘b’, ‘c’, ‘d’] => [‘b’, ‘c’, ‘d’]; slice(:-1): [‘a’, ‘b’, ‘c’, ‘d’] => [‘a’, ‘b’, ‘c’]; slice(::-1): [‘a’, ‘b’, ‘c’, ‘d’] => [‘d’, ‘c’, ‘b’, ‘a’]. See also sslice().</p></li>
<li><p><cite>sslice(start:stop:step)</cite>: [s(tring) slice] Slice values in a list using same semantics as Python’s string slicing, e.g. sslice(1:3):’abcd => ‘bc’; sslice(1:4:2): ‘abcd’ => ‘bd’, etc. See also slice().</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">filter(x)</span></code>: Filter list of values using predicate x; for example, <code class="docutils literal notranslate"><span class="pre">{folder_album|filter(contains</span> <span class="pre">Events)}</span></code> returns only folders/albums containing the word ‘Events’ in their path.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">int</span></code>: Convert values in list to integer, e.g. 1.0 => 1. If value cannot be converted to integer, remove value from list. [‘1.1’, ‘x’] => [‘1’]. See also float.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">float</span></code>: Convert values in list to floating point number, e.g. 1 => 1.0. If value cannot be converted to float, remove value from list. [‘1’, ‘x’] => [‘1.0’]. See also int.</p></li>
</ul>
<p>e.g. if Photo keywords are <code class="docutils literal notranslate"><span class="pre">["FOO","bar"]</span></code>:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{keyword|lower}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"foo",</span> <span class="pre">"bar"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{keyword|upper}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"FOO",</span> <span class="pre">"BAR"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{keyword|capitalize}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"Foo",</span> <span class="pre">"Bar"</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{keyword|lower|parens}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"(foo)",</span> <span class="pre">"(bar)"</span></code></p></li>
</ul>
<p>e.g. if Photo description is “my description”:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{descr|titlecase}"</span></code> renders to: <code class="docutils literal notranslate"><span class="pre">"My</span> <span class="pre">Description"</span></code></p></li>
</ul>
<p>e.g. If Photo is in <code class="docutils literal notranslate"><span class="pre">Album1</span></code> in <code class="docutils literal notranslate"><span class="pre">Folder1</span></code>:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{folder_album}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">["Folder1/Album1"]</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{folder_album(>)}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">["Folder1>Album1"]</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{folder_album()}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">["Folder1Album1"]</span></code></p></li>
</ul>
<p><cite>[find,replace]</cite>: optional text replacement to perform on rendered template value. For example, to replace “/” in an album name, you could use the template <cite>“{album[/,-]}”</cite>. Multiple replacements can be made by appending “|” and adding another find|replace pair. e.g. to replace both “/” and “:” in album name: <code class="docutils literal notranslate"><span class="pre">"{album[/,-|:,-]}"</span></code>. find/replace pairs are not limited to single characters. The “|” character cannot be used in a find/replace pair.</p>
<p><cite>conditional</cite>: optional conditional expression that is evaluated as boolean (True/False) for use with the <cite>?bool_value</cite> modifier. Conditional expressions take the form ‘<cite>not operator value</cite>’ where <cite>not</cite> is an optional modifier that negates the <cite>operator</cite>. Note: the space before the conditional expression is required if you use a conditional expression. Valid comparison operators are:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">contains</span></code>: template field contains value, similar to python’s <code class="docutils literal notranslate"><span class="pre">in</span></code></p></li>
<li><p><cite>matches</cite>: template field contains exactly value, unlike <cite>contains</cite>: does not match partial matches</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">startswith</span></code>: template field starts with value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">endswith</span></code>: template field ends with value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre"><=</span></code>: template field is less than or equal to value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">>=</span></code>: template field is greater than or equal to value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre"><</span></code>: template field is less than value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">></span></code>: template field is greater than value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">==</span></code>: template field equals value</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">!=</span></code>: template field does not equal value</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">value</span></code> part of the conditional expression is treated as a bare (unquoted) word/phrase. Multiple values may be separated by ‘|’ (the pipe symbol). <code class="docutils literal notranslate"><span class="pre">value</span></code> is itself a template statement so you can use one or more template fields in <code class="docutils literal notranslate"><span class="pre">value</span></code> which will be resolved before the comparison occurs.</p>
<p>For example:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">{keyword</span> <span class="pre">matches</span> <span class="pre">Beach}</span></code> resolves to True if ‘Beach’ is a keyword. It would not match keyword ‘BeachDay’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">{keyword</span> <span class="pre">contains</span> <span class="pre">Beach}</span></code> resolves to True if any keyword contains the word ‘Beach’ so it would match both ‘Beach’ and ‘BeachDay’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">{photo.score.overall</span> <span class="pre">></span> <span class="pre">0.7}</span></code> resolves to True if the photo’s overall aesthetic score is greater than 0.7.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">{keyword|lower</span> <span class="pre">contains</span> <span class="pre">beach}</span></code> uses the lower case filter to do case-insensitive matching to match any keyword that contains the word ‘beach’.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">{keyword|lower</span> <span class="pre">not</span> <span class="pre">contains</span> <span class="pre">beach}</span></code> uses the <code class="docutils literal notranslate"><span class="pre">not</span></code> modifier to negate the comparison so this resolves to True if there is no keyword that matches ‘beach’.</p></li>
</ul>
<p>Examples: to export photos that contain certain keywords with the <code class="docutils literal notranslate"><span class="pre">osxphotos</span> <span class="pre">export</span></code> command’s <code class="docutils literal notranslate"><span class="pre">--directory</span></code> option:</p>
<p><code class="docutils literal notranslate"><span class="pre">--directory</span> <span class="pre">"{keyword|lower</span> <span class="pre">matches</span> <span class="pre">travel|vacation?Travel-Photos,Not-Travel-Photos}"</span></code></p>
<p>This exports any photo that has keywords ‘travel’ or ‘vacation’ into a directory ‘Travel-Photos’ and all other photos into directory ‘Not-Travel-Photos’.</p>
<p>This can be used to rename files as well, for example:
<code class="docutils literal notranslate"><span class="pre">--filename</span> <span class="pre">"{favorite?Favorite-{original_name},{original_name}}"</span></code></p>
<p>This renames any photo that is a favorite as ‘Favorite-ImageName.jpg’ (where ‘ImageName.jpg’ is the original name of the photo) and all other photos with the unmodified original name.</p>
<p><code class="docutils literal notranslate"><span class="pre">?bool_value</span></code>: Template fields may be evaluated as boolean (True/False) by appending “?” after the field name (and following “(field_arg)” or “[find/replace]”. If a field is True (e.g. photo is HDR and field is <code class="docutils literal notranslate"><span class="pre">"{hdr}"</span></code>) or has any value, the value following the “?” will be used to render the template instead of the actual field value. If the template field evaluates to False (e.g. in above example, photo is not HDR) or has no value (e.g. photo has no title and field is <code class="docutils literal notranslate"><span class="pre">"{title}"</span></code>) then the default value following a “,” will be used.</p>
<p>e.g. if photo is an HDR image,</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{hdr?ISHDR,NOTHDR}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"ISHDR"</span></code></p></li>
</ul>
<p>and if it is not an HDR image,</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{hdr?ISHDR,NOTHDR}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"NOTHDR"</span></code></p></li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">,default</span></code>: optional default value to use if the template name has no value. This modifier is also used for the value if False for boolean-type fields (see above) as well as to hold a sub-template for values like <code class="docutils literal notranslate"><span class="pre">{created.strftime}</span></code>. If no default value provided, “_” is used.</p>
<p>e.g., if photo has no title set,</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{title}"</span></code> renders to “_”</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">"{title,I</span> <span class="pre">have</span> <span class="pre">no</span> <span class="pre">title}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"I</span> <span class="pre">have</span> <span class="pre">no</span> <span class="pre">title"</span></code></p></li>
</ul>
<p>Template fields such as <code class="docutils literal notranslate"><span class="pre">created.strftime</span></code> use the default value to pass the template to use for <code class="docutils literal notranslate"><span class="pre">strftime</span></code>.</p>
<p>e.g., if photo date is 4 February 2020, 19:07:38,</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">"{created.strftime,%Y-%m-%d-%H%M%S}"</span></code> renders to <code class="docutils literal notranslate"><span class="pre">"2020-02-04-190738"</span></code></p></li>
</ul>
<p>Some template fields such as <code class="docutils literal notranslate"><span class="pre">"{media_type}"</span></code> use the default value to allow customization of the output. For example, <code class="docutils literal notranslate"><span class="pre">"{media_type}"</span></code> resolves to the special media type of the photo such as <code class="docutils literal notranslate"><span class="pre">panorama</span></code> or <code class="docutils literal notranslate"><span class="pre">selfie</span></code>. You may use the default value to override these in form: <code class="docutils literal notranslate"><span class="pre">"{media_type,video=vidéo;time_lapse=vidéo_accélérée}"</span></code>. In this example, if photo was a time_lapse photo, <code class="docutils literal notranslate"><span class="pre">media_type</span></code> would resolve to <code class="docutils literal notranslate"><span class="pre">vidéo_accélérée</span></code> instead of <code class="docutils literal notranslate"><span class="pre">time_lapse</span></code>.</p>
<p>Either or both bool_value or default (False value) may be empty which would result in empty string <code class="docutils literal notranslate"><span class="pre">""</span></code> when rendered.</p>
<p>If you want to include “{” or “}” in the output, use “{openbrace}” or “{closebrace}” template substitution.</p>
<p>e.g. <code class="docutils literal notranslate"><span class="pre">"{created.year}/{openbrace}{title}{closebrace}"</span></code> would result in <code class="docutils literal notranslate"><span class="pre">"2020/{Photo</span> <span class="pre">Title}"</span></code>.</p>
<p><strong>Variables</strong></p>
<p>You can define variables for later use in the template string using the format <code class="docutils literal notranslate"><span class="pre">{var:NAME,VALUE}</span></code> where <code class="docutils literal notranslate"><span class="pre">VALUE</span></code> is a template statement. Variables may then be referenced using the format <code class="docutils literal notranslate"><span class="pre">%NAME</span></code>. For example: <code class="docutils literal notranslate"><span class="pre">{var:foo,bar}</span></code> defines the variable <code class="docutils literal notranslate"><span class="pre">%foo</span></code> to have value <code class="docutils literal notranslate"><span class="pre">bar</span></code>. This can be useful if you want to re-use a complex template value in multiple places within your template string or for allowing the use of characters that would otherwise be prohibited in a template string. For example, the “pipe” (<code class="docutils literal notranslate"><span class="pre">|</span></code>) character is not allowed in a find/replace pair but you can get around this limitation like so: <code class="docutils literal notranslate"><span class="pre">{var:pipe,{pipe}}{title[-,%pipe]}</span></code> which replaces the <code class="docutils literal notranslate"><span class="pre">-</span></code> character with <code class="docutils literal notranslate"><span class="pre">|</span></code> (the value of <code class="docutils literal notranslate"><span class="pre">%pipe</span></code>).</p>
<p>Variables can also be referenced as fields in the template string, for example: <code class="docutils literal notranslate"><span class="pre">{var:year,{created.year}}{original_name}-{%year}</span></code>. In some cases, use of variables can make your template string more readable. Variables can be used as template fields, as values for filters, as values for conditional operations, or as default values. When used as a conditional value or default value, variables should be treated like any other field and enclosed in braces as conditional and default values are evaluated as template strings. For example: <code class="docutils literal notranslate"><span class="pre">{var:name,Katie}{person</span> <span class="pre">contains</span> <span class="pre">{%name}?{%name},Not-{%name}}</span></code>.</p>
<p>If you need to use a <code class="docutils literal notranslate"><span class="pre">%</span></code> (percent sign character), you can escape the percent sign by using <code class="docutils literal notranslate"><span class="pre">%%</span></code>. You can also use the <code class="docutils literal notranslate"><span class="pre">{percent}</span></code> template field where a template field is required. For example:</p>
<p><code class="docutils literal notranslate"><span class="pre">{title[:,%%]}</span></code> replaces the <code class="docutils literal notranslate"><span class="pre">:</span></code> with <code class="docutils literal notranslate"><span class="pre">%</span></code> and <code class="docutils literal notranslate"><span class="pre">{title</span> <span class="pre">contains</span> <span class="pre">Foo?{title}{percent},{title}}</span></code> adds <code class="docutils literal notranslate"><span class="pre">%</span></code> to the title if it contains <code class="docutils literal notranslate"><span class="pre">Foo</span></code>.</p>
<section id="id1">
<h2>Template Substitutions<a class="headerlink" href="#id1" title="Link to this heading">#</a></h2>
<div class="table-wrapper docutils container">
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Field</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>{name}</p></td>
<td><p>Current filename of the photo</p></td>
</tr>
<tr class="row-odd"><td><p>{original_name}</p></td>
<td><p>Photo’s original filename when imported to Photos</p></td>
</tr>
<tr class="row-even"><td><p>{title}</p></td>
<td><p>Title of the photo</p></td>
</tr>
<tr class="row-odd"><td><p>{descr}</p></td>
<td><p>Description of the photo</p></td>
</tr>
<tr class="row-even"><td><p>{media_type}</p></td>
<td><p>Special media type resolved in this precedence: selfie, time_lapse, panorama, slow_mo, screenshot, portrait, live_photo, burst, photo, video. Defaults to ‘photo’ or ‘video’ if no special type. Customize one or more media types using format: ‘{media_type,video=vidéo;time_lapse=vidéo_accélérée}’</p></td>
</tr>
<tr class="row-odd"><td><p>{photo_or_video}</p></td>
<td><p>‘photo’ or ‘video’ depending on what type the image is. To customize, use default value as in ‘{photo_or_video,photo=fotos;video=videos}’</p></td>
</tr>
<tr class="row-even"><td><p>{hdr}</p></td>
<td><p>Photo is HDR?; True/False value, use in format ‘{hdr?VALUE_IF_TRUE,VALUE_IF_FALSE}’</p></td>
</tr>
<tr class="row-odd"><td><p>{edited}</p></td>
<td><p>True if photo has been edited (has adjustments), otherwise False; use in format ‘{edited?VALUE_IF_TRUE,VALUE_IF_FALSE}’</p></td>
</tr>
<tr class="row-even"><td><p>{edited_version}</p></td>
<td><p>True if template is being rendered for the edited version of a photo, otherwise False.</p></td>
</tr>
<tr class="row-odd"><td><p>{favorite}</p></td>
<td><p>Photo has been marked as favorite?; True/False value, use in format ‘{favorite?VALUE_IF_TRUE,VALUE_IF_FALSE}’</p></td>
</tr>
<tr class="row-even"><td><p>{created}</p></td>
<td><p>Photo’s creation date in ISO format, e.g. ‘2020-03-22’</p></td>
</tr>
<tr class="row-odd"><td><p>{created.date}</p></td>
<td><p>Photo’s creation date in ISO format, e.g. ‘2020-03-22’</p></td>
</tr>
<tr class="row-even"><td><p>{created.year}</p></td>
<td><p>4-digit year of photo creation time</p></td>
</tr>
<tr class="row-odd"><td><p>{created.yy}</p></td>
<td><p>2-digit year of photo creation time</p></td>
</tr>
<tr class="row-even"><td><p>{created.mm}</p></td>
<td><p>2-digit month of the photo creation time (zero padded)</p></td>
</tr>
<tr class="row-odd"><td><p>{created.month}</p></td>
<td><p>Month name in user’s locale of the photo creation time</p></td>
</tr>
<tr class="row-even"><td><p>{created.mon}</p></td>
<td><p>Month abbreviation in the user’s locale of the photo creation time</p></td>
</tr>
<tr class="row-odd"><td><p>{created.dd}</p></td>
<td><p>2-digit day of the month (zero padded) of photo creation time</p></td>
</tr>
<tr class="row-even"><td><p>{created.dow}</p></td>
<td><p>Day of week in user’s locale of the photo creation time</p></td>
</tr>
<tr class="row-odd"><td><p>{created.doy}</p></td>
<td><p>3-digit day of year (e.g Julian day) of photo creation time, starting from 1 (zero padded)</p></td>
</tr>
<tr class="row-even"><td><p>{created.hour}</p></td>
<td><p>2-digit hour of the photo creation time</p></td>
</tr>
<tr class="row-odd"><td><p>{created.min}</p></td>
<td><p>2-digit minute of the photo creation time</p></td>
</tr>
<tr class="row-even"><td><p>{created.sec}</p></td>
<td><p>2-digit second of the photo creation time</p></td>
</tr>
<tr class="row-odd"><td><p>{created.strftime}</p></td>
<td><p>Apply strftime template to file creation date/time. Should be used in form {created.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. {created.strftime,%Y-%U} would result in year-week number of year: ‘2020-23’. If used with no template will return null value. See <a class="reference external" href="https://strftime.org/">https://strftime.org/</a> for help on strftime templates.</p></td>
</tr>
<tr class="row-even"><td><p>{modified}</p></td>
<td><p>Photo’s modification date in ISO format, e.g. ‘2020-03-22’; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.date}</p></td>
<td><p>Photo’s modification date in ISO format, e.g. ‘2020-03-22’; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.year}</p></td>
<td><p>4-digit year of photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.yy}</p></td>
<td><p>2-digit year of photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.mm}</p></td>
<td><p>2-digit month of the photo modification time (zero padded); uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.month}</p></td>
<td><p>Month name in user’s locale of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.mon}</p></td>
<td><p>Month abbreviation in the user’s locale of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.dd}</p></td>
<td><p>2-digit day of the month (zero padded) of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.dow}</p></td>
<td><p>Day of week in user’s locale of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.doy}</p></td>
<td><p>3-digit day of year (e.g Julian day) of photo modification time, starting from 1 (zero padded); uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.hour}</p></td>
<td><p>2-digit hour of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.min}</p></td>
<td><p>2-digit minute of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-even"><td><p>{modified.sec}</p></td>
<td><p>2-digit second of the photo modification time; uses creation date if photo is not modified</p></td>
</tr>
<tr class="row-odd"><td><p>{modified.strftime}</p></td>
<td><p>Apply strftime template to file modification date/time. Should be used in form {modified.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. {modified.strftime,%Y-%U} would result in year-week number of year: ‘2020-23’. If used with no template will return null value. Uses creation date if photo is not modified. See <a class="reference external" href="https://strftime.org/">https://strftime.org/</a> for help on strftime templates.</p></td>
</tr>
<tr class="row-even"><td><p>{today}</p></td>
<td><p>Current date in iso format, e.g. ‘2020-03-22’</p></td>
</tr>
<tr class="row-odd"><td><p>{today.date}</p></td>
<td><p>Current date in iso format, e.g. ‘2020-03-22’</p></td>
</tr>
<tr class="row-even"><td><p>{today.year}</p></td>
<td><p>4-digit year of current date</p></td>
</tr>
<tr class="row-odd"><td><p>{today.yy}</p></td>
<td><p>2-digit year of current date</p></td>
</tr>
<tr class="row-even"><td><p>{today.mm}</p></td>
<td><p>2-digit month of the current date (zero padded)</p></td>
</tr>
<tr class="row-odd"><td><p>{today.month}</p></td>
<td><p>Month name in user’s locale of the current date</p></td>
</tr>
<tr class="row-even"><td><p>{today.mon}</p></td>
<td><p>Month abbreviation in the user’s locale of the current date</p></td>
</tr>
<tr class="row-odd"><td><p>{today.dd}</p></td>
<td><p>2-digit day of the month (zero padded) of current date</p></td>
</tr>
<tr class="row-even"><td><p>{today.dow}</p></td>
<td><p>Day of week in user’s locale of the current date</p></td>
</tr>
<tr class="row-odd"><td><p>{today.doy}</p></td>
<td><p>3-digit day of year (e.g Julian day) of current date, starting from 1 (zero padded)</p></td>
</tr>
<tr class="row-even"><td><p>{today.hour}</p></td>
<td><p>2-digit hour of the current date</p></td>
</tr>
<tr class="row-odd"><td><p>{today.min}</p></td>
<td><p>2-digit minute of the current date</p></td>
</tr>
<tr class="row-even"><td><p>{today.sec}</p></td>
<td><p>2-digit second of the current date</p></td>
</tr>
<tr class="row-odd"><td><p>{today.strftime}</p></td>
<td><p>Apply strftime template to current date/time. Should be used in form {today.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. {today.strftime,%Y-%U} would result in year-week number of year: ‘2020-23’. If used with no template will return null value. See <a class="reference external" href="https://strftime.org/">https://strftime.org/</a> for help on strftime templates.</p></td>
</tr>
<tr class="row-even"><td><p>{place.name}</p></td>
<td><p>Place name from the photo’s reverse geolocation data, as displayed in Photos</p></td>
</tr>
<tr class="row-odd"><td><p>{place.country_code}</p></td>
<td><p>The ISO country code from the photo’s reverse geolocation data</p></td>
</tr>
<tr class="row-even"><td><p>{place.name.country}</p></td>
<td><p>Country name from the photo’s reverse geolocation data</p></td>
</tr>
<tr class="row-odd"><td><p>{place.name.state_province}</p></td>
<td><p>State or province name from the photo’s reverse geolocation data</p></td>
</tr>
<tr class="row-even"><td><p>{place.name.city}</p></td>
<td><p>City or locality name from the photo’s reverse geolocation data</p></td>
</tr>
<tr class="row-odd"><td><p>{place.name.area_of_interest}</p></td>
<td><p>Area of interest name (e.g. landmark or public place) from the photo’s reverse geolocation data</p></td>
</tr>
<tr class="row-even"><td><p>{place.address}</p></td>
<td><p>Postal address from the photo’s reverse geolocation data, e.g. ‘2007 18th St NW, Washington, DC 20009, United States’</p></td>
</tr>
<tr class="row-odd"><td><p>{place.address.street}</p></td>
<td><p>Street part of the postal address, e.g. ‘2007 18th St NW’</p></td>
</tr>
<tr class="row-even"><td><p>{place.address.city}</p></td>
<td><p>City part of the postal address, e.g. ‘Washington’</p></td>
</tr>
<tr class="row-odd"><td><p>{place.address.state_province}</p></td>
<td><p>State/province part of the postal address, e.g. ‘DC’</p></td>
</tr>
<tr class="row-even"><td><p>{place.address.postal_code}</p></td>
<td><p>Postal code part of the postal address, e.g. ‘20009’</p></td>
</tr>
<tr class="row-odd"><td><p>{place.address.country}</p></td>
<td><p>Country name of the postal address, e.g. ‘United States’</p></td>
</tr>
<tr class="row-even"><td><p>{place.address.country_code}</p></td>
<td><p>ISO country code of the postal address, e.g. ‘US’</p></td>
</tr>
<tr class="row-odd"><td><p>{searchinfo.season}</p></td>
<td><p>Season of the year associated with a photo, e.g. ‘Summer’; (Photos 5+ only, applied automatically by Photos’ image categorization algorithms).</p></td>
</tr>
<tr class="row-even"><td><p>{exif.camera_make}</p></td>
<td><p>Camera make from original photo’s EXIF information as imported by Photos, e.g. ‘Apple’</p></td>
</tr>
<tr class="row-odd"><td><p>{exif.camera_model}</p></td>
<td><p>Camera model from original photo’s EXIF information as imported by Photos, e.g. ‘iPhone 6s’</p></td>
</tr>
<tr class="row-even"><td><p>{exif.lens_model}</p></td>
<td><p>Lens model from original photo’s EXIF information as imported by Photos, e.g. ‘iPhone 6s back camera 4.15mm f/2.2’</p></td>
</tr>
<tr class="row-odd"><td><p>{moment}</p></td>
<td><p>The moment title of the photo</p></td>
</tr>
<tr class="row-even"><td><p>{uuid}</p></td>
<td><p>Photo’s internal universally unique identifier (UUID) for the photo, a 36-character string unique to the photo, e.g. ‘128FB4C6-0B16-4E7D-9108-FB2E90DA1546’</p></td>
</tr>
<tr class="row-odd"><td><p>{shortuuid}</p></td>
<td><p>A shorter representation of photo’s internal universally unique identifier (UUID) for the photo, a 22-character string unique to the photo, e.g. ‘JYsxugP9UjetmCbBCHXcmu’</p></td>
</tr>
<tr class="row-even"><td><p>{id}</p></td>
<td><p>A unique number for the photo based on its primary key in the Photos database. A sequential integer, e.g. 1, 2, 3…etc. Each asset associated with a photo (e.g. an image and Live Photo preview) will share the same id. May be formatted using a python string format code. For example, to format as a 5-digit integer and pad with zeros, use ‘{id:05d}’ which results in 00001, 00002, 00003…etc.</p></td>
</tr>
<tr class="row-odd"><td><p>{counter}</p></td>
<td><p>A sequential counter, starting at 0, that increments each time it is evaluated.To start counting at a value other than 0, append append ‘(starting_value)’ to the field name.For example, to start counting at 1 instead of 0: ‘{counter(1)}’.May be formatted using a python string format code.For example, to format as a 5-digit integer and pad with zeros, use ‘{counter:05d(1)}’which results in 00001, 00002, 00003…etc.You may also specify a stop value which causes the counter to reset to the starting valuewhen the stop value is reached and a step size which causes the counter to increment bythe specified value instead of 1. Use the format ‘{counter(start,stop,step)}’ where start,stop, and step are integers. For example, to count from 1 to 10 by 2, use ‘{counter(1,11,2)}’.Note that the counter stops counting when the stop value is reached and does not return thestop value. Start, stop, and step are optional and may be omitted. For example, to countfrom 0 by 2s, use ‘{counter(,,2)}’.You may create an arbitrary number of counters by appending a unique name to the field namepreceded by a period: ‘{counter.a}’, ‘{counter.b}’, etc. Each counter will have its own stateand will start at 0 and increment by 1 unless otherwise specified. Note: {counter} is not suitable for use with ‘export’ and ‘–update’ as the counter associated with a photo may change between export sessions. See also {id}.</p></td>
</tr>
<tr class="row-even"><td><p>{album_seq}</p></td>
<td><p>An integer, starting at 0, indicating the photo’s index (sequence) in the containing album. Only valid when used in a ‘–filename’ template and only when ‘{album}’ or ‘{folder_album}’ is used in the ‘–directory’ template. For example ‘–directory “{folder_album}” –filename “{album<em>seq}</em>{original_name}”’. To start counting at a value other than 0, append append ‘(starting_value)’ to the field name. For example, to start counting at 1 instead of 0: ‘{album_seq(1)}’. May be formatted using a python string format code. For example, to format as a 5-digit integer and pad with zeros, use ‘{album_seq:05d}’ which results in 00000, 00001, 00002…etc. To format while also using a starting value: ‘{album_seq:05d(1)}’ which results in 0001, 00002…etc.This may result in incorrect sequences if you have duplicate albums with the same name; see also ‘{folder_album_seq}’.</p></td>
</tr>
<tr class="row-odd"><td><p>{folder_album_seq}</p></td>
<td><p>An integer, starting at 0, indicating the photo’s index (sequence) in the containing album and folder path. Only valid when used in a ‘–filename’ template and only when ‘{folder_album}’ is used in the ‘–directory’ template. For example ‘–directory “{folder_album}” –filename “{folder_album<em>seq}</em>{original_name}”’. To start counting at a value other than 0, append ‘(starting_value)’ to the field name. For example, to start counting at 1 instead of 0: ‘{folder_album_seq(1)}’ May be formatted using a python string format code. For example, to format as a 5-digit integer and pad with zeros, use ‘{folder_album_seq:05d}’ which results in 00000, 00001, 00002…etc. To format while also using a starting value: ‘{folder_album_seq:05d(1)}’ which results in 0001, 00002…etc.This may result in incorrect sequences if you have duplicate albums with the same name in the same folder; see also ‘{album_seq}’.</p></td>
</tr>
<tr class="row-even"><td><p>{comma}</p></td>
<td><p>A comma: ‘,’</p></td>
</tr>
<tr class="row-odd"><td><p>{semicolon}</p></td>
<td><p>A semicolon: ‘;’</p></td>
</tr>
<tr class="row-even"><td><p>{questionmark}</p></td>
<td><p>A question mark: ‘?’</p></td>
</tr>
<tr class="row-odd"><td><p>{pipe}</p></td>
<td><p>A vertical pipe: ‘|’</p></td>
</tr>
<tr class="row-even"><td><p>{openbrace}</p></td>
<td><p>An open brace: ‘{’</p></td>
</tr>
<tr class="row-odd"><td><p>{closebrace}</p></td>
<td><p>A close brace: ‘}’</p></td>
</tr>
<tr class="row-even"><td><p>{openparens}</p></td>
<td><p>An open parentheses: ‘(’</p></td>
</tr>
<tr class="row-odd"><td><p>{closeparens}</p></td>
<td><p>A close parentheses: ‘)’</p></td>
</tr>
<tr class="row-even"><td><p>{openbracket}</p></td>
<td><p>An open bracket: ‘[’</p></td>
</tr>
<tr class="row-odd"><td><p>{closebracket}</p></td>
<td><p>A close bracket: ‘]’</p></td>
</tr>
<tr class="row-even"><td><p>{newline}</p></td>
<td><p>A newline: ‘n’</p></td>
</tr>
<tr class="row-odd"><td><p>{lf}</p></td>
<td><p>A line feed: ‘n’, alias for {newline}</p></td>
</tr>
<tr class="row-even"><td><p>{cr}</p></td>
<td><p>A carriage return: ‘r’</p></td>
</tr>
<tr class="row-odd"><td><p>{crlf}</p></td>
<td><p>A carriage return + line feed: ‘rn’</p></td>
</tr>
<tr class="row-even"><td><p>{tab}</p></td>
<td><dl class="field-list simple">
<dt class="field-odd">A tab<span class="colon">:</span></dt>
<dd class="field-odd"><p>‘t’</p>
</dd>
</dl>
</td>
</tr>
<tr class="row-odd"><td><p>{osxphotos_version}</p></td>
<td><p>The osxphotos version, e.g. ‘0.63.4’</p></td>
</tr>
<tr class="row-even"><td><p>{osxphotos_cmd_line}</p></td>
<td><p>The full command line used to run osxphotos</p></td>
</tr>
<tr class="row-odd"><td><p>{album}</p></td>
<td><p>Album(s) photo is contained in</p></td>
</tr>
<tr class="row-even"><td><p>{folder_album}</p></td>
<td><p>Folder path + album photo is contained in. e.g. ‘Folder/Subfolder/Album’ or just ‘Album’ if no enclosing folder</p></td>
</tr>
<tr class="row-odd"><td><p>{project}</p></td>
<td><p>Project(s) photo is contained in (such as greeting cards, calendars, slideshows)</p></td>
</tr>
<tr class="row-even"><td><p>{album_project}</p></td>
<td><p>Album(s) and project(s) photo is contained in; treats projects as regular albums</p></td>
</tr>
<tr class="row-odd"><td><p>{folder_album_project}</p></td>
<td><p>Folder path + album (includes projects as albums) photo is contained in. e.g. ‘Folder/Subfolder/Album’ or just ‘Album’ if no enclosing folder</p></td>
</tr>
<tr class="row-even"><td><p>{keyword}</p></td>
<td><p>Keyword(s) assigned to photo</p></td>
</tr>
<tr class="row-odd"><td><p>{person}</p></td>
<td><p>Person(s) / face(s) in a photo</p></td>
</tr>
<tr class="row-even"><td><p>{label}</p></td>
<td><p>Image categorization label associated with a photo (Photos 5+ only). Labels are added automatically by Photos using machine learning algorithms to categorize images. These are not the same as {keyword} which refers to the user-defined keywords/tags applied in Photos.</p></td>
</tr>
<tr class="row-odd"><td><p>{label_normalized}</p></td>
<td><p>All lower case version of ‘label’ (Photos 5+ only)</p></td>
</tr>
<tr class="row-even"><td><p>{comment}</p></td>
<td><p>Comment(s) on shared Photos; format is ‘Person name: comment text’ (Photos 5+ only)</p></td>
</tr>
<tr class="row-odd"><td><p>{exiftool}</p></td>
<td><p>Format: ‘{exiftool:GROUP:TAGNAME}’; use exiftool (https://exiftool.org) to extract metadata, in form GROUP:TAGNAME, from image. E.g. ‘{exiftool:EXIF:Make}’ to get camera make, or {exiftool:IPTC:Keywords} to extract keywords. See https://exiftool.org/TagNames/ for list of valid tag names. You must specify group (e.g. EXIF, IPTC, etc) as used in <code class="docutils literal notranslate"><span class="pre">exiftool</span> <span class="pre">-G</span></code>. exiftool must be installed in the path to use this template.</p></td>
</tr>
<tr class="row-even"><td><p>{searchinfo.holiday}</p></td>
<td><p>Holiday names associated with a photo, e.g. ‘Christmas Day’; (Photos 5+ only, applied automatically by Photos’ image categorization algorithms).</p></td>
</tr>
<tr class="row-odd"><td><p>{searchinfo.activity}</p></td>
<td><p>Activities associated with a photo, e.g. ‘Sporting Event’; (Photos 5+ only, applied automatically by Photos’ image categorization algorithms).</p></td>
</tr>
<tr class="row-even"><td><p>{searchinfo.venue}</p></td>
<td><p>Venues associated with a photo, e.g. name of restaurant; (Photos 5+ only, applied automatically by Photos’ image categorization algorithms).</p></td>
</tr>
<tr class="row-odd"><td><p>{searchinfo.venue_type}</p></td>
<td><p>Venue types associated with a photo, e.g. ‘Restaurant’; (Photos 5+ only, applied automatically by Photos’ image categorization algorithms).</p></td>
</tr>
<tr class="row-even"><td><p>{photo}</p></td>
<td><p>Provides direct access to the PhotoInfo object for the photo. Must be used in format ‘{photo.property}’ where ‘property’ represents a PhotoInfo property. For example: ‘{photo.favorite}’ is the same as ‘{favorite}’ and ‘{photo.place.name}’ is the same as ‘{place.name}’. ‘{photo}’ provides access to properties that are not available as separate template fields but it assumes some knowledge of the underlying PhotoInfo class. See <a class="reference external" href="https://rhettbull.github.io/osxphotos/">https://rhettbull.github.io/osxphotos/</a> for additional documentation on the PhotoInfo class.</p></td>
</tr>
<tr class="row-odd"><td><p>{detected_text}</p></td>
<td><p>List of text strings found in the image after performing text detection. Using ‘{detected_text}’ will cause osxphotos to perform text detection on your photos using the built-in macOS text detection algorithms which will slow down your export. The results for each photo will be cached in the export database so that future exports with ‘–update’ do not need to reprocess each photo. You may pass a confidence threshold value between 0.0 and 1.0 after a colon as in ‘{detected_text:0.5}’; The default confidence threshold is 0.75. ‘{detected_text}’ works only on macOS Catalina (10.15) or later. Note: this feature is not the same thing as Live Text in macOS Monterey, which osxphotos does not yet support.</p></td>
</tr>
<tr class="row-even"><td><p>{shell_quote}</p></td>
<td><p>Use in form ‘{shell_quote,TEMPLATE}’; quotes the rendered TEMPLATE value(s) for safe usage in the shell, e.g. My file.jpeg => ‘My file.jpeg’; only adds quotes if needed.</p></td>
</tr>
<tr class="row-odd"><td><p>{strip}</p></td>
<td><p>Use in form ‘{strip,TEMPLATE}’; strips whitespace from begining and end of rendered TEMPLATE value(s).</p></td>
</tr>
<tr class="row-even"><td><p>{format}</p></td>
<td><p>Use in form, ‘{format:TYPE:FORMAT,TEMPLATE}’; converts TEMPLATE value to TYPE then formats the value using Python string formatting codes specified by FORMAT; TYPE is one of: ‘int’, ‘float’, or ‘str’. For example, ‘{format:float:.1f,{exiftool:EXIF:FocalLength}}’ will format focal length to 1 decimal place (e.g. ‘100.0’).</p></td>
</tr>
<tr class="row-odd"><td><p>{function}</p></td>
<td><p>Execute a python function from an external file and use return value as template substitution. Use in format: {function:file.py::function_name} where ‘file.py’ is the name of the python file and ‘function_name’ is the name of the function to call. The function will be passed the PhotoInfo object for the photo. See https://github.com/RhetTbull/osxphotos/blob/master/examples/template_function.py for an example of how to implement a template function.</p></td>
</tr>
</tbody>
</table>
</div>
</section>
</section>
</article>
</div>
<footer>
<div class="related-pages">
<a class="next-page" href="package_overview.html">
<div class="page-info">
<div class="context">
<span>Next</span>
</div>
<div class="title">OSXPhotos Python Package Overview</div>
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
<a class="prev-page" href="cli.html">
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
<div class="page-info">
<div class="context">
<span>Previous</span>
</div>
<div class="title">OSXPhotos Command Line Interface (CLI)</div>
</div>
</a>
</div>
<div class="bottom-of-page">
<div class="left-details">
<div class="copyright">
Copyright © 2021, Rhet Turnbull
</div>
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
<a href="https://github.com/pradyunsg/furo">Furo</a>
</div>
<div class="right-details">
</div>
</div>
</footer>
</div>
<aside class="toc-drawer">
<div class="toc-sticky toc-scroll">
<div class="toc-title-container">
<span class="toc-title">
On this page
</span>
</div>
<div class="toc-tree-container">
<div class="toc-tree">
<ul>
<li><a class="reference internal" href="#">OSXPhotos Template System</a><ul>
<li><a class="reference internal" href="#id1">Template Substitutions</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</aside>
</div>
</div><script src="_static/documentation_options.js?v=903a5549"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/furo.js?v=32e29ea5"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
</body>
</html>