file rename syntax examples/help

the codes for renaming files are too complicated for my simple brain.. I always used Zotfile, and it was very easy to arrange it like this:

In the case of one or two authors my filename would end up like:
author1 author2 year - title - CallNumber.extension

In the case of more than two authors:
author1 author2 ea year - title - CallNumber.extension

The CallNumber was only the first part of the call number, I had to edit that manually

And all files were renamed, not only pdf. I use Zotero also for a lot of docx's.

If anyone could help or redirect me to examples, that would be much appreciated!

  • The following template should create filenames as you've described:

    {{ if {{ authors match="[^,]+,[^,]+,[^,]+" }} }}
    {{ authors max="2" suffix=" ea" }}
    {{ else }}
    {{ authors }}
    {{ endif }}
    {{ year prefix=" " }}
    {{ title prefix=" - " }}
    {{ callNumber prefix=" - " }}


    It's generally quite straightforward, except there is currently no easy way to append a suffix only if the number of authors exceeds a certain limit, so the syntax above uses regex matching (lines 1–5). We're planning to simplify this a bit in the future.
    And all files were renamed, not only PDFs. I use Zotero also for a lot of DOCX files.
    There is a list of common file types to select in the preferences, but docx is not on the list at the moment. It can, however, be added using the advanced preference editor. Go to Preferences -> Advanced -> Config Editor. In the window that appears, search for autoRenameFiles.fileTypes, edit the value, and append the following type after a comma:

    application/vnd.openxmlformats-officedocument.wordprocessingml.document

    This will enable file renaming for docx. You might also want to append application/msword (again, separated with a comma) to include doc.
  • Thanks a lot! A real improvement.
    Strangely enough, in the preview (in settings), the Call Number is shown. But on the actual file change, it does not add the Call Number. Any idea why?
    I'm not very fond on special characters in file names. Is it possible to remover the comma (,) between the Authors? I tried messing with the comma's in the scripts, to no avail.
    And it would be great if special characters were replaced by regular one's: ö, or ó -> o, etc. That was also a very nice Zotfile feature.
  • Strangely enough, in the preview (in settings), the Call Number is shown. But on the actual file change, it does not add the Call Number. Any idea why?
    Is the Call Number field populated for the parent item for this file?
    Is it possible to remover the comma (,) between the Authors?
    You can use the join parameter. For example, to use just a space character to separate consecutive authors, replace the second line in the above template with the following:

    {{ authors join=" " max="2" suffix=" ea" }}
    And it would be great if special characters were replaced by regular one's: ö, or ó -> o, etc. That was also a very nice Zotfile feature.
    It's currently not possible, but we've had this request before and may add this feature in the future.
  • Oops, I see now that the pdf I use for testing was open in pdf-reader. That blocks the name change without warning. Sorry, mistake -> Call Number is added!

    The comma to space is strange: It works with > 2 authors, but not with <3 authors. In that case still the comma is used.

    Something else has changed: names can only be changed right-clicking on the pdf. Not on the parent. That generates extra clicks, but more important: it seems impossible to initiate this action on more than one file at once.. I used to select a range of entries and let Zotfile do the job. No more. That's really a setback. Bug?

    Again thank you for your time!
    jasper
  • In that case still the comma is used.
    Oh yes, the 4th line of the original template also should include the join parameter, something like: {{ authors join=" " }}
    Something else has changed: names can only be changed right-clicking on the pdf.
    See: https://forums.zotero.org/discussion/comment/480572/#Comment_480572
Sign In or Register to comment.