filename renaming with multiple authors
When renaming PDF files, my goal is to list all authors if there're 2 or less, and use the first-author et al. format if there're 3 or more. For example,
Social Research Methods 5e (Canadian edition): Bryman, Bell_2019_Social research methods.pdf
Social Research Methods 6e: Clark et al._2021_Bryman's social research methods.pdf
if I set the filename template as: {{ authors max="2" suffix="_" }}{{ year suffix="_" }}{{ title }}, I'll get:
Bryman, Bell_2019_Social research methods.pdf
Clark, Forster_2021_Bryman's social research methods.pdf
if I set the filename template as: {{ firstCreator suffix="_" }}{{ year suffix="_" }}{{ title }}, I'll get:
Bryman and Bell_2019_Social research methods.pdf
Clark et al._2021_Bryman's social research methods.pdf
{{ authors max="2"}} will truncate the authors at 2 without et al. and {{ firstCreator }} uses "and" when there're 2 authors, neither of which can work as I intended.
{{ firstCreator join=", " }} doesn't work because join works for authors, editors, and creators. Please share your suggestion to this issue, thanks a lot!
Social Research Methods 5e (Canadian edition): Bryman, Bell_2019_Social research methods.pdf
Social Research Methods 6e: Clark et al._2021_Bryman's social research methods.pdf
if I set the filename template as: {{ authors max="2" suffix="_" }}{{ year suffix="_" }}{{ title }}, I'll get:
Bryman, Bell_2019_Social research methods.pdf
Clark, Forster_2021_Bryman's social research methods.pdf
if I set the filename template as: {{ firstCreator suffix="_" }}{{ year suffix="_" }}{{ title }}, I'll get:
Bryman and Bell_2019_Social research methods.pdf
Clark et al._2021_Bryman's social research methods.pdf
{{ authors max="2"}} will truncate the authors at 2 without et al. and {{ firstCreator }} uses "and" when there're 2 authors, neither of which can work as I intended.
{{ firstCreator join=", " }} doesn't work because join works for authors, editors, and creators. Please share your suggestion to this issue, thanks a lot!
Upgrade Storage
{{ if {{ authors match="[^,]+,[^,]+,[^,]+" }} }}
{{ authors max="1" suffix=" et al._" }}
{{ else }}
{{ authors join=" and " suffix="_" }}
{{ endif }}
{{ year suffix="_"}}
{{ title }}
The file renaming template currently does not support counting authors, but we can use a regular expression to check if there are at least three authors. If that's the case, the first branch executes, producing
author et al.. If there are fewer than three authors, the second branch executes, producingauthor and author. The remaining part of the template adds a year (suffixed with "_"), followed by the title.authorsfield doesn't include them.{{ if {{ creators match="[^,]+,[^,]+,[^,]+" }} }}
{{ creators max="1" suffix=" et al._" }}
{{ else }}
{{ creators join=", " suffix="_" }}
{{ endif }}
{{ year suffix="_"}}
{{ title }}
In this case I can have books with 2 authors like:
McQuail, Windahl_1993_Communication models for the study of mass communications.pdf
and books with more than 3 authors like:
Clark et al._2021_Bryman's social research methods.pdf