Option for "et al" instead of "et al." in renaming rules

I'm really impressed with the rollout of Zotero 7!

I'm currently migrating all my plugins and workflows, and one extremely minor issue is that I can't find a way to customize how et al is spelled and formatted. To keep things consistent with my prior workflow (which relied on zotfile for file renaming), I would like to be able to set it so et al is not followed by a period. But it might also be nice to "explode" the firstCreator variable and ensure greater customization capabilities too. I realize that this is probably a very low priority, but it could be important for people who run local automation/scripting that relies on consistent file-naming patterns.
  • It might not be as user-friendly, but you can already achieve this using regex replacement.

    {{ firstCreator replaceFrom="et al.$" replaceTo="et al" }}

    With some additional effort, it's possible to use authors with formatting and logical statements to replace firstCreator. Here's an example from another thread:

    https://forums.zotero.org/discussion/comment/470491/#Comment_470491
  • Thanks for this regex, it does exactly what I need!
  • edited August 14, 2024
    How would I format it so Zotero uses "&" instead of "and" for two authors (to match APA 7 style)?
  • edited August 14, 2024
    You can use {{ authors join="&" }}.

    By default, the authors are joined with a comma (,) rather than the word "and".

    Please refer to the file renaming documentation for more details.
  • Use join=" & " within the double brackets for creators/authors.
    https://www.zotero.org/support/file_renaming#customizing_the_filename_format
  • edited August 15, 2024
    @tnajdek, that works, but it won't follow APA 7 style.

    Output example when the reference has 4 authors:
    "AuthA & AuthB & AuthC & AuthD" instead of "AuthA et al"

    @tim820, that "join" feature doesn't work with "firstCreator"
    So I use {{ firstCreator join="&" }}, which follows the APA 7 style but uses the word "and" instead of "&"

    Output example when the reference has 2 authors:
    "AuthA and AuthB"

    Output example when the reference has 3 or more authors:
    "AuthA et al"

    I've played around with it using the documentation. I don't think there is a quick one line fix
  • You can customize authors yourself, here is an example that will result in AuthA et al for three or more authors, but for two it will produce AuthA & AuthB for two authors.

    {{ if {{ authors match="[^,]+,[^,]+,[^,]+" }} }}
    {{ authors max="1" suffix=" et al" }}
    {{ else }}
    {{ authors join=" & " }}
    {{ endif }}
  • edited August 27, 2024
    @tnajdek, the example code works, but for some reason, when I try to include the year, the outcome is like this for two authors:
    "AuthA & AuthB ( 2024) RandomTitleHere.pdf"
    For three authors:
    "AuthA et al. ( 2024) RandomTitleHere.pdf"

    I think using authors just adds one " " (i.e., one space) in between open-paracentesis.

    Here is the code I am using:

    {{ if {{ authors match="[^,]+,[^,]+,[^,]+" }} }}
    {{ authors max="1" suffix=" et al. (" }}{{ year suffix=") " }}{{ title truncate="30" }}
    {{ else }}
    {{ authors join=" & " suffix=" (" }}{{ year suffix=") " }}{{ title truncate="30" }}
    {{ endif }}


    Furthermore, it breaks if I have 1 and 4 or more authors. I have experimented with code, but I can't think of solving this elegantly or without hard coding.
  • firstCreator variable is useful as it nearly does what I want, thanks to the back-end of codes doing the heavy lifting. But because the back-end code spits out "and", I can't simply write something to replace "and" to "&"
  • I'd move the opening bracket from suffix on authors to prefix on year. This makes more logical sense and also fixes cases where the date field is empty.

    I've tested the exact code you provided and couldn't identify the problem with having one or four authors, so you'll need to be more specific. I also wasn't able to reproduce the extra space inside the bracket. Does it appear in the preview when editing the template in the Zotero preferences pane?
  • edited September 1, 2024
    I came here trying to find a way to change the join character for firstCreator (which does a good job easily selecting whatever creator the reference has and limiting it's lenght for the file name), and tnajdek's suggestion above works fine.

    I still think it would be more obvious and easier to allow most of the author/editor parameters (join, name... would be some useful ones) for firstCreator as well.

    Thanks again in any case, I got things working as I wanted!
  • I have a similar issue but I have no idea how resolve it. I want to rename the PDFs in folders using this pattern: (First author)_(date)_(Title).

    Now I have this: {{ firstCreator suffix="_" }}{{ year suffix="_" }}{{ title truncate="75" }}

    But I don't want two authors neither "et al." when is more than two.
    Can anyone help me please?
  • Now yes! Thank you very much tim820.
    Very helpful.
Sign In or Register to comment.