Options for "AND" or non-blank in file renaming?

I'm using the following syntax for PDF file renaming

```
{{ if itemType == "journalArticle" }}
{{ publicationTitle suffix=" - " }}{{ year suffix=" - v" }}{{ volume suffix="-" }}{{ issue suffix=" - pp" }}{{ pages suffix=" - " }}{{ firstCreator suffix=" - " }}{{ title truncate="100" }}

{{ elseif itemType == "journalArticle" }}
{{ journalAbbreviation suffix=" - " }}{{ year suffix=" - v" }}{{ volume suffix="-" }}{{ issue suffix=" - pp" }}{{ pages suffix=" - " }}{{ firstCreator suffix=" - " }}{{ title truncate="100" }}

{{ elseif itemType == "book" }}
{{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="100" }}
{{ else }}
{{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="100" }}
{{ endif }}
```

I'd like to modulate this slightly so that items in the database which have a non-blank entry for the journalAbbreviation field, will swap that in for {{ publicationTitle suffix=" - " }}, e.g. {{ journalAbbreviation suffix=" - " }}.

I'm not really sure how to add these layers as it's not clear what the syntax is for AND in logic statements in zotero. Has anyone else had more luck with this?
  • @dstillman @tnajdek Would it be possible to have shortTitle and journalAbbreviation automatically fall back to their long form fields if they are missing?
  • That’s worth considering. That being said, it’s possible with the current system — you can use match to check the content of one field and then decide to use it or fall back to another. Here is an example where journalAbbreviation is used if present, and publicationTitle otherwise:

    {{ if {{ journalAbbreviation match="^.+$" }} }}
    {{ journalAbbreviation }}
    {{ else }}
    {{ publicationTitle }}
    {{ endif }}
  • That worked perfectly. Here's my final code:

    {{ if itemType == "journalArticle" }}
    {{ if {{ journalAbbreviation match="^.+$" }} }}
    {{ journalAbbreviation suffix=" - " }}
    {{ else }}
    {{ publicationTitle suffix=" - " }}
    {{ endif }}{{ year suffix=" - v" }}{{ volume suffix="-" }}{{ issue suffix=" - pp" }}{{ pages suffix=" - " }}{{ firstCreator suffix=" - " }}{{ title truncate="100" }}

    {{ elseif itemType == "book" }}
    {{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="100" }}
    {{ else }}
    {{ firstCreator suffix=" - " }}{{ year suffix=" - " }}{{ title truncate="100" }}
    {{ endif }}
Sign In or Register to comment.