When renaming use et al_ instead of et al._

Dear all,

I want to recreate the ZotFile settings I used when customising the file name format with Zotero7.

If I have a file with multiple creators (e.g., Author, Colleague, and Student) and a long title with subtitle (e.g., This Is The Main Title: Why the subtitle should be removed) I want the resulting file name to be Author et al_2025_This Is The Main Title.pdf

I am struggling with the first part, I haven't attempted the second part yet.

I have tried a small change, based on how I understand the syntax:

{{ firstCreator suffix="_" replaceFrom"." replaceTo""}}
{{ year suffix="_" }}
{{ title truncate="100" }}

This does not work the way I expect at all.

How do I get _both_ parts of my desired outcome?


All the best,

Quincy
  • edited 18 days ago
    I think I almost solved the first part based on this thread: https://forums.zotero.org/discussion/120628/file-rename-syntax-examples-help/p1

    I now have Author_2025_This Is The Main Title: Why the subtitle should be removed.pdf for a singular author and Author et al_2025_This Is The Main Title: Why the subtitle should be removed.pdf for two or more authors

    {{ if {{ authors match="[^,]+,[^,]+" }} }}
    {{ authors max="1" suffix=" et al_" }}
    {{ else }}
    {{ firstCreator suffix= "_"}}
    {{ endif }}
    {{ year suffix="_" }}
    {{ title truncate="100" }}

    It doesn't work when there are editors only. I tried with replacing authors by creators everywhere, but that didn't work as expected.


    I still have try to understand how to do the latter part of my desired outcome
  • How do I solve the second part?

    I have solved the first part with an elseif clause.

    {{ if {{ authors match="[^,]+,[^,]+" }} }}
    {{ authors max="1" suffix=" et al_" }}
    {{ elseif {{ editors match="[^,]+,[^,]+" }} }}
    {{ editors max="1" suffix=" et al_" }}
    {{ else }}
    {{ firstCreator suffix= "_"}}
    {{ endif }}
    {{ year suffix="_" }}
    {{ title truncate="100" }}
  • Unless I misunderstand what you're trying to achieve, the template you've posted will not work as expected when there is just one author but two or more editors. In such a case, it will end up using only the name of the first editor. You might want to add another if statement to check if there is just one author, something like this:

    {{ if {{ authors match="^[^,]+$" }} }}
    {{ authors suffix="_" }}
    {{ elseif {{ authors match="[^,]+,[^,]+" }} }}
    {{ authors max="1" suffix=" et al_" }}
    {{ elseif {{ editors match="[^,]+,[^,]+" }} }}
    {{ editors max="1" suffix=" et al_" }}
    {{ else }}
    {{ firstCreator suffix= "_"}}
    {{ endif }}


    A better way of handling various numbers of creators in file renaming is a fairly common request, and we may simplify this in the future.
    How do I solve the second part?
    Is this about splitting title and subtitle that you've mentioned in the first post? One way to approach this would be to use a regular expression to match everything up to a first occurrence of ":" character:

    {{ title replaceFrom="^((?:[^:])+).*$" replaceTo="$1" }}
  • @tnajdek

    Thank you so much.

    So far with testing the code I shared seemed to work with singular authors too, but I'll put it in to ensure robustness

    > Is this about splitting title and subtitle that you've mentioned in the first post?

    yes exactly,

    I ended up with "{{ title replaceFrom=":.*" replaceTo=}}", This seemed to work, would you see any issues with that version?
  • would you see any issues with that version?
    Sure, that should work as well.
Sign In or Register to comment.