Fixed typo in template help

This commit is contained in:
Rhet Turnbull 2023-08-05 07:31:33 -07:00
parent 3f74eeff44
commit d1d6938581
2 changed files with 83 additions and 45 deletions

124
README.md
View File

@ -1117,7 +1117,7 @@ Options:
of different types but the same name in the of different types but the same name in the
output directory, e.g. 'IMG_1234.JPG' and output directory, e.g. 'IMG_1234.JPG' and
'IMG_1234.MOV'. 'IMG_1234.MOV'.
--sidecar-template MAKO_TEMPLATE_FILE SIDECAR_FILENAME_TEMPLATE WRITE_SKIPPED STRIP_WHITESPACE STRIP_LINES --sidecar-template MAKO_TEMPLATE_FILE SIDECAR_FILENAME_TEMPLATE OPTIONS
Create a custom sidecar file for each photo Create a custom sidecar file for each photo
exported with user provided Mako template exported with user provided Mako template
(MAKO_TEMPLATE_FILE). MAKO_TEMPLATE_FILE must (MAKO_TEMPLATE_FILE). MAKO_TEMPLATE_FILE must
@ -1135,31 +1135,40 @@ Options:
filename of the sidecar file. The `{filepath}` filename of the sidecar file. The `{filepath}`
template variable may be used in the template variable may be used in the
SIDECAR_FILENAME_TEMPLATE to refer to the SIDECAR_FILENAME_TEMPLATE to refer to the
filename of the photo being exported. filename of the photo being exported. OPTIONS
WRITE_SKIPPED is a boolean value (true/false, is a comma-separated list of strings providing
yes/no, 1/0 are all valid values) and additional options to the template. Valid
indicates whether or not write the sidecar options are: write_skipped, strip_whitespace,
file even if the photo is skipped during strip_lines, skip_zero, catch_errors, none.
export. If WRITE_SKIPPED is false, the sidecar write_skipped will cause the sidecar file to
file will not be written if the photo is be written even if the photo is skipped during
skipped during export. If WRITE_SKIPPED is export. If write_skipped is not passed as an
true, the sidecar file will be written even if option, the sidecar file will not be written
the photo is skipped during export. if the photo is skipped during export.
STRIP_WHITESPACE and STRIP_LINES are boolean strip_whitespace and strip_lines indicate
values (true/false, yes/no, 1/0 are all valid whether or not to strip whitespace and blank
values) and indicate whether or not to strip lines, respectively, from the resulting
whitespace and blank lines from the resulting sidecar file. skip_zero causes the sidecar
sidecar file. For example, to create a 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 file with extension .xmp using a template file
named 'sidecar.mako' and write a sidecar for named 'sidecar.mako' and write a sidecar for
skipped photos and strip blank lines but not skipped photos and strip blank lines but not
whitespace: `--sidecar-template sidecar.mako whitespace: `--sidecar-template sidecar.mako
'{filepath}.xmp' yes no yes`. To do the same '{filepath}.xmp' write_skipped,strip_lines`.
but to drop the photo extension from the To do the same but to drop the photo extension
sidecar filename: `--sidecar-template from the sidecar filename: `--sidecar-template
sidecar.mako sidecar.mako
'{filepath.parent}/{filepath.stem}.xmp' yes no '{filepath.parent}/{filepath.stem}.xmp'
yes --sidecar-drop-ext`. For an example Mako 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/Rhe file see https://raw.githubusercontent.com/Rhe
tTbull/osxphotos/main/examples/custom_sidecar. tTbull/osxphotos/main/examples/custom_sidecar.
mako mako
@ -1343,30 +1352,59 @@ Options:
scripts or other files. Be sure this is what scripts or other files. Be sure this is what
you intend before using --cleanup. Use --dry- you intend before using --cleanup. Use --dry-
run with --cleanup first if you're not run with --cleanup first if you're not
certain. certain. To prevent files not generated by
--keep KEEP_PATH When used with --cleanup, prevents file or osxphotos from being deleted, you may specify
directory KEEP_PATH from being deleted when one or more rulesin a file named
cleanup is run. Use this if there are files in `.osxphotos_keep` in the export directory.
the export directory that you don't want to be This file uses the same format as a .gitignore
deleted when --cleanup is run. KEEP_PATH may file and should contain one rule per line;
be a file path, e.g. lines starting with a `#` will be ignored.
'/Volumes/Photos/keep.jpg', or a file path and Reference https://git-
wild card, e.g. '/Volumes/Photos/*.txt', or a scm.com/docs/gitignore#_pattern_format for
directory, e.g. '/Volumes/Photos/KeepMe'. details. In addition to the standard
KEEP_PATH may be an absolute path or a .gitignore rules, the rules may also be the
relative path. If it is relative, it must be absolute path to a file or directory. For
relative to the export destination. For
example if export destination is example if export destination is
`/Volumes/Photos` and you want to keep all `/Volumes/Photos` and you want to keep all
`.txt` files, you can specify `--keep `.txt` files, in the top level of the export
"/Volumes/Photos/*.txt"` or `--keep "*.txt"`. directory, you can specify `/*.txt"` in the
If wild card is used, KEEP_PATH must be .osxphotos_keep file. If you want to keep all
enclosed in quotes to prevent the shell from `.txt` files in the export directory and all
expanding the wildcard, e.g. `--keep subdirectories, you can specify `**/*.txt`. If
"/Volumes/Photos/*.txt"`. If KEEP_PATH is a present, the .osxphotos_keep file will be read
directory, all files and directories contained after the export is completed and any rules
in KEEP_PATH will be kept. --keep may be found in the file will be added to the list of
repeated to keep additional files/directories. 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 --add-exported-to-album ALBUM Add all exported photos to album ALBUM in
Photos. Album ALBUM will be created if it Photos. Album ALBUM will be created if it
doesn't exist. All exported photos will be doesn't exist. All exported photos will be

View File

@ -149,9 +149,9 @@ e.g. `"{created.year}/{openbrace}{title}{closebrace}"` would result in `"2020/{P
**Variables** **Variables**
You can define variables for later use in the template string using the format `{var:NAME,VALUE}` where `VALUE` may be a raw string or another template field enclosed in `{}`. Variables may then be referenced using the format `%NAME`. For example: `{var:foo,bar}` defines the variable `%foo` to have value `bar`. 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" (`|`) character is not allowed in a find/replace pair but you can get around this limitation like so: `{var:pipe,{pipe}}{title[-,%pipe]}` which replaces the `-` character with `|` (the value of `%pipe`). You can define variables for later use in the template string using the format `{var:NAME,VALUE}`. Variables may then be referenced using the format `%NAME`. For example: `{var:foo,bar}` defines the variable `%foo` to have value `bar`. 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" (`|`) character is not allowed in a find/replace pair but you can get around this limitation like so: `{var:pipe,{pipe}}{title[-,%pipe]}` which replaces the `-` character with `|` (the value of `%pipe`).
Variables can also be referenced as fields in the template string, for example: `{var:year,{created.year}}{original_name}-{%year}`. 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: `{var:name,Katie}{person contains {%name}?{%name},Not-{%name}}`. Variables can also be referenced as fields in the template string, for example: `{var:year,created.year}{original_name}-{%year}`. 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: `{var:name,Katie}{person contains {%name}?{%name},Not-{%name}}`.
If you need to use a `%` (percent sign character), you can escape the percent sign by using `%%`. You can also use the `{percent}` template field where a template field is required. For example: If you need to use a `%` (percent sign character), you can escape the percent sign by using `%%`. You can also use the `{percent}` template field where a template field is required. For example: