Both sides previous revisionPrevious revisionNext revision | Previous revision |
file_renaming [2025/04/05 05:56] – Add authorsCount, editorsCount and creatorsCount tnajdek | file_renaming [2025/04/16 11:47] (current) – Fixed a small copy-paste error tnajdek |
---|
| ''regexOpts'' | All | 'i' | Defines [[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags|flags]] to use when matching using regular expressions (see ''replaceFrom''). For example, ''%%{{ title replaceFrom="\s+" regexOpts="g" }}%%'' is substituted with the parent item's title with all white space removed (without ''regexOpts'', only the first white space would be removed). | | | ''regexOpts'' | All | 'i' | Defines [[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags|flags]] to use when matching using regular expressions (see ''replaceFrom''). For example, ''%%{{ title replaceFrom="\s+" regexOpts="g" }}%%'' is substituted with the parent item's title with all white space removed (without ''regexOpts'', only the first white space would be removed). | |
| ''match'' | All | | Use a regular expression to test for a matching string in the variable. This parameter is useful in conditions and it cannot be used with any other parameters, except for ''regexOpts''. For example, the following template will only return the parent item's URL if the URL's domain name is zotero.org: ''%%{{ if {{ url match="^https?://zotero.org.*?$" }} }}{{ url }}{{ endif }}%%''. | | | ''match'' | All | | Use a regular expression to test for a matching string in the variable. This parameter is useful in conditions and it cannot be used with any other parameters, except for ''regexOpts''. For example, the following template will only return the parent item's URL if the URL's domain name is zotero.org: ''%%{{ if {{ url match="^https?://zotero.org.*?$" }} }}{{ url }}{{ endif }}%%''. | |
| ''max'' | ''authors'', ''editors'', ''creators'' | | Limits number of creators to use, e.g., ''%%{{ editors max="1" }}%%'' will be replaced with first editor of parent's item. It can be configured with ''regexOpts'' parameter. | | | ''max'' | ''authors'', ''editors'', ''creators'' | | Limits number of creators to use, e.g., ''%%{{ editors max="1" }}%%'' will be replaced with first editor of parent's item. | |
| ''name'' | ''authors'', ''editors'', ''creators'' | ''family'' | Customizes how creator name appears in the filename, with the following accepted options: ''family-given'' will use full name of the creator, beginning with family (last) name of the creator, ''given-family'' also uses full name but inverts the order, and options ''given'' and ''family'' will only use part of the parent item's creator's name. | | | ''name'' | ''authors'', ''editors'', ''creators'' | ''family'' | Customizes how creator name appears in the filename, with the following accepted options: ''family-given'' will use full name of the creator, beginning with family (last) name of the creator, ''given-family'' also uses full name but inverts the order, and options ''given'' and ''family'' will only use part of the parent item's creator's name. | |
| ''name-part-separator'' | ''authors'', ''editors'', ''creators'' | '' ''(single space character) | Defines what characters to use to separate given and family name, especially useful when combined with ''initialize''. | | | ''name-part-separator'' | ''authors'', ''editors'', ''creators'' | '' ''(single space character) | Defines what characters to use to separate given and family name, especially useful when combined with ''initialize''. | |
A year of publication, followed by a hyphen-separated list of authors, followed by a title truncated at 30 characters: | A year of publication, followed by a hyphen-separated list of authors, followed by a title truncated at 30 characters: |
| |
Template: ''%%{{ year suffix="-" }}{{ authors name="family-given" initialize="given" initialize="-" join="-" suffix="-" case="hyphen" }}{{ title truncate="30" case="hyphen" }}%%'' | Template: |
| <code>{{ year suffix="-" }} |
| {{ authors name="family-given" initialize="given" initialize="-" join="-" suffix="-" case="hyphen" }} |
| {{ title truncate="30" case="hyphen" }} |
| </code> |
| |
Filename: ''2023-lee-sukbae-kim-ji-hoon-kwon-young-wan-the-first-room-temperature-amb.pdf'' | Filename: ''2023-lee-sukbae-kim-ji-hoon-kwon-young-wan-the-first-room-temperature-amb.pdf'' |
Anything not included inside a ''%%{{%%'' bracket is copied to the filename literally: | Anything not included inside a ''%%{{%%'' bracket is copied to the filename literally: |
| |
Template: ''%%{{ itemType localize="true" }} from {{ year }} by {{ authors max="1" name="given-family" initialize="given" }}%%'' | Template: |
| <code>{{ itemType localize="true" }} from {{ year }} by {{ authors max="1" name="given-family" initialize="given" }} |
| </code> |
| |
Filename: ''Preprint from 2023 by S. Lee.pdf'' | Filename: ''Preprint from 2023 by S. Lee.pdf'' |
{{ title }} | {{ title }} |
{{ endif }}</code> | {{ endif }}</code> |
| |
| As of Zotero 7.1, it's possible to compare numeric values like ''authorsCount'' using relational operators such as ''<'', ''%%<=%%'', ''>'', and ''>=''. For example, the following template checks the number of authors: if there are two or more, it uses the first author's name followed by et al.; if there are one or two authors, it includes all their names in the filename. |
| |
| <code> |
| {{ if {{ authorsCount > 2 }} }} |
| {{ authors max="1" suffix=" et al" }} |
| {{ else }} |
| {{ authors join=" & " }} |
| {{ endif }} |
| </code> |
| |
It's possible to use regular expressions to match values and change the behavior of the template. For example, the following template preserves common attachment names (such as "Full Text"), but for attachments with non-matching titles, it uses the standard Zotero filename template: | It's possible to use regular expressions to match values and change the behavior of the template. For example, the following template preserves common attachment names (such as "Full Text"), but for attachments with non-matching titles, it uses the standard Zotero filename template: |