Zotero 7 file renaming customization — truncate title after colon
As I try to replicate the functionality I once had with ZotFile, I've run into one (not all that major) roadblock for now.
The format I used to use with ZotFile was "{%F} ({%y}) - {%t}"
Which in plain words is "author’s last name with first letter of first name" then "year" and finally "title truncated after : . ? or after a maximum number of characters"
I can replicate the beginning, before the title, with this:
{{ if firstCreator == creators }} {{ firstCreator name="family-given" initialize="given" initialize-with="" name-part-separator="" }}
{{else}}
{{ creators name="family-given" join = " and " initialize="given" initialize-with="" name-part-separator="" max = "2" suffix=" et al" }}{{ endif }}
({{year}}) -
And for now I will probably just use the default {{ title truncate="100" }}.
But I am curious if it is currently possible to either truncate as soon as one of those characters appears, or as a secondary option, to conditionally use a short title if it exists and if not, then use the full title truncated after a specified number of characters. I know the templates have the ability for if/else logic, but I'm unsure how to test for the existence of a field.
For the latter approach, it *seems* like this works:
{{ if shortTitle=="" }} {{ title truncate="100"}}{{else}}
{{ shortTitle truncate="100" }}{{endif}}
But I don't know if it's a robust/safe approach to use `==""` to check for whether there's anything in that field. Maybe empty fields are always stored as zero-length strings, but I don't know.
Thanks to Zotero team and community for all the support and the massive improvements implemented in these last few years.
The format I used to use with ZotFile was "{%F} ({%y}) - {%t}"
Which in plain words is "author’s last name with first letter of first name" then "year" and finally "title truncated after : . ? or after a maximum number of characters"
I can replicate the beginning, before the title, with this:
{{ if firstCreator == creators }} {{ firstCreator name="family-given" initialize="given" initialize-with="" name-part-separator="" }}
{{else}}
{{ creators name="family-given" join = " and " initialize="given" initialize-with="" name-part-separator="" max = "2" suffix=" et al" }}{{ endif }}
({{year}}) -
And for now I will probably just use the default {{ title truncate="100" }}.
But I am curious if it is currently possible to either truncate as soon as one of those characters appears, or as a secondary option, to conditionally use a short title if it exists and if not, then use the full title truncated after a specified number of characters. I know the templates have the ability for if/else logic, but I'm unsure how to test for the existence of a field.
For the latter approach, it *seems* like this works:
{{ if shortTitle=="" }} {{ title truncate="100"}}{{else}}
{{ shortTitle truncate="100" }}{{endif}}
But I don't know if it's a robust/safe approach to use `==""` to check for whether there's anything in that field. Maybe empty fields are always stored as zero-length strings, but I don't know.
Thanks to Zotero team and community for all the support and the massive improvements implemented in these last few years.