Zotero 7: Will renaming be as robust as ZotFile's?
dstillman
Zotero Team
This discussion was created from comments split from: Automatic file renaming not reported properly in Zotero 7.
Upgrade Storage
For example, Zotfile allows regex changes to particular fields. You can also specify subfolders based on various criteria (collection, type, creator, etc.).
With the last options included, I think that the module to rename files in Zotero 7 is extremely powerful (much more than zotfile!!!)... hopefully it can also be complemented with the possibility of predefining (and creating if necessary), the subfolders where they should be saved to.
Zotero only creates stored files when saving, so I'm afraid folder creation is out of scope for Zotero itself.
I was referring to linked attachments, not Zotero-stored ones. Zotfile allows two kinds of "renaming": one template for the filename itself, another for the subfolder where you want the linked attachment to land (outside Zotero storage). This is useful for those who like to manage their own attachment structure.
One could imagine a preference such as "Specify subfolder for linked attachments?" with a subpreference for the subfolder destination, using a template syntax much like the existing one for renaming.
Of course, all this assumes an option for renaming AND moving attachments out of Zotero, which I realize is controversial. But judging by the many comments around attachment storage, it would be welcome.
One of the users of my plugin wants to include journal abbreviations in the filename (the most simplified journal abbreviation, containing only the first letter of the full name of the journal, e.g. cem. eng. j. would be abbreviated as CEJ), and he expects to store the CEJ in the journal abbreviation field to make it easier for the file renaming feature to use it.
However, I would strongly discourage this, as I believe that the journal abbreviation field should always store the correct iso4 abbreviation, so I would expect it to be stored in extra, but the current file renaming feature does not support the use of the data in extra.
Any thoughts on adding this support please?
Add regex find-and-replace parameter for all variables.
Add firstCollection variable, ideally returning the first and topmost collection name of the parent item.
Add urlHost variable, returning only the www.domain.com portion of the parent item's url.
Add truncatedTitle variable. Akin to shortTitle but returns a title stripped of any period, question mark or colon, plus anything after it, so the file name can use the equivalent of a shortTitle even where none has been entered in the parent item's metadata.
Allow use of logical operators (and, or, not, xor) in renaming syntax.
Allow if statements evaluating the number of creators to be compared with integers using equals, greater-than and less-than operators.
Allow parameter “join” to work with firstCreator variable, so users can set an "and" alternative.
Provide option for user-defined “et al.” string for use with with firstCreator.
Allow multiple variables in a single bracket, separated by an exclusive operator, for instance, " | ". In this case, the first variable in the list to match would prevail. This would reduce the need for lengthy "if ... elseif" structures.
Allow bracketed statements to be nested.
Provide additional option for simplifying special characters, e.g., removing curly quotes and apostrophes, diacritics on Latin letters, etc., to ensure valid, easily searchable file names across operating systems.
Provide option for suppressing suffixes where they would create a repeat character, e.g. two hyphens, two periods etc.
key: valuefields from Extra, but we can consider making that possible. (The regexp support suggested by @ria3k would be one option.)There are a few things I really like in Zotfile that it would be great to see in the built in renaming. Some of these are already covered by @ria3k and I'll just be seconding them.
1. authors, editors, creators should have an "etal" option for when the number of items exceeds the "max" value. This should also be customizable. Then, one could replicate the "firstCreator" variable with {{creators max=2 join=" and " etal="et al."}}
2. Zotero has a nice abbreviate function, Zotero.Cite.getAbbreviation, that can abbreviate titles of papers, journals, books, etc. I added that function in Zotfile so that I could use publicationTitle abbreviations in the file name (https://github.com/jlegewie/zotfile/blob/a6c9e02e17b60cbc1f9bb4062486548d9ef583e3/chrome/content/zotfile/wildcards.js#L14). Having an "abbreviate" function would be great since you could then not simply truncate, but abbreviate long titles.
3. regex or replace function. I like to have filenames without spaces and it would be nice to be able to remove/replace them or other characters in the file name components.
For now, I've found a workaround that adds "et al" when there are 2 or more authors but omits "et al" when there is only 1 author. For anyone interested, here is the Filename Template code, which allows me to replicate the functionality which I previously used ZotFile for (in Zotero 6):
{{ if firstCreator == creators }} {{ firstCreator }}
{{else }} {{ creators join = " & " max = "2" suffix=" et al" }} {{ endif }}
The main limitation is that only a single regex replacement is possible, so you can't perform multiple replacements in sequence. If there's interest I can try to figure out a way to add that feature.
{{ if editors == "" }} {{ if {{ creators }} == {{ creators max="2" }} }} {{ creators max="2" join="+" suffix="#" case="snake" }} {{ else }} {{ creators max="1" suffix="_etal#" case="snake" }} {{ endif }} {{ else }} {{ if {{ editors }} == {{ editors max="2" }} }} {{ editors max="2" join="+" suffix="#" case="snake" }} {{ else }} {{ editors max="1" suffix="_etal#" case="snake" }} {{ endif }} {{ endif }} {{ year suffix="#"}} {{ title truncate="28" case="snake" }}
Edit as needed.
I think the "abbreviate" function would still be quite useful and easy to implement. I'd happy to take a stab too if you'd look at a pull request.