Both sides previous revisionPrevious revisionNext revision | Previous revision |
file_renaming [2025/04/05 10:29] – Add example that uses relational operators and authorsCount 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''. | |
{{ endif }}</code> | {{ endif }}</code> |
| |
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. | 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> | <code> |