You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the r/osxphotos Reddit page, someone recently asked how to combine multiple templates for the --directory option so they could export to both YYYY/MM/DD and Folder/Album format. This wasn't possible without a custom template function. However, after thinking about this for a while I decided to add a new combine operator to the OSXPhotos Template Language spec to make this possible. To use it, you add &{template} immediately after the field name in your template. The result is the value(s) of the combined template are appended to the value(s) of the original template. This produces a multi-valued result so it can only be used in templates that can handle this (for example, --directory, --filename).
&combine_value: Template fields may be combined with another template statement to return multiple values. The combine_value is another template statement. For example, the template {created.year&{folder_album,}} would resolve to ["1999", "Vacation"] if the photo was created in 1999 and was in the album Vacation. Because the combine_value is a template statement, multiple templates may be combined together by nesting the combine operator: {template1&{template2&{template3,},},}. In this example, a null default value is used to prevent the default value from being combined if any of the nested templates does not resolve to a value.
For example, the template that works for the OP's question on Reddit is:
This creates a new value (stored in a variable) called folder_date which is the date of the photo in YYYY/MM/DD format as you'd get with --export-by-date and then adds zero or more values for the folder/album for any folders/albums the photos is in.
This will result in duplicate exported copies so that's something to be aware of.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
On the r/osxphotos Reddit page, someone recently asked how to combine multiple templates for the
--directory
option so they could export to bothYYYY/MM/DD
andFolder/Album
format. This wasn't possible without a custom template function. However, after thinking about this for a while I decided to add a newcombine
operator to the OSXPhotos Template Language spec to make this possible. To use it, you add&{template}
immediately after the field name in your template. The result is the value(s) of the combined template are appended to the value(s) of the original template. This produces a multi-valued result so it can only be used in templates that can handle this (for example,--directory
,--filename
).&combine_value
: Template fields may be combined with another template statement to return multiple values. The combine_value is another template statement. For example, the template{created.year&{folder_album,}}
would resolve to ["1999", "Vacation"] if the photo was created in 1999 and was in the album Vacation. Because the combine_value is a template statement, multiple templates may be combined together by nesting the combine operator:{template1&{template2&{template3,},},}
. In this example, a null default value is used to prevent the default value from being combined if any of the nested templates does not resolve to a value.For example, the template that works for the OP's question on Reddit is:
--directory "{var:folder_date,{created.year}/{created.mm}/{created.dd}}{%folder_date&{folder_album,}}"
This creates a new value (stored in a variable) called
folder_date
which is the date of the photo inYYYY/MM/DD
format as you'd get with--export-by-date
and then adds zero or more values for thefolder/album
for any folders/albums the photos is in.This will result in duplicate exported copies so that's something to be aware of.
Edit: this is available in osxphotos v0.67.8.
Beta Was this translation helpful? Give feedback.
All reactions