Attachment File Naming Conventions

edited April 15, 2020
Hello -

Is there any way to set up different automatic attachment file-naming conventions for different types of media?

My usual manual file-naming protocol, which I've used for years:

Book:
Author(s) - Title [publisher, edition, year].pdf

Anthology, Encyclopedia, Reference Work: (omits author(s) and editor(s)):
Title [optional publisher, edition, year].pdf

Article:
Author(s) - "Title" [journal or anthology, year].pdf

The quotation marks, for example, are used only for articles, so this makes easy quick differentiation of articles from books. That standard is derived from the use of quotation marks for article titles within citations in Chicago style. Leaving off the authors for certain types of works (reference works, anthologies, encyclopedias) also makes those easy to identify at a glance.

Presumably such is impossible with Zotero or any add-ons? I've been experimenting with Zotfile as well, but it only seems to allow a single naming convention for all of the above categories of media. Zotfile also still seems to default to moving the files into the Zotero database when re-naming, rather than just re-naming linked files and leaving them in their place.

(Note that I use my own file organization system, not Zotero's built-in database. I organize the files topically and thematically on the computer; thus I use Mac's Finder and folder hierarchy to organize these files. I use aliases if a given article falls under multiple topics and themes. So for example an article on Skepticism would be filed in Philosophy:Skepticism with an alias in Philosophy:Epistemology; if the author has a folder of his/her own, then either the alias or original would also go in that folder; and so on.)

Any suggestions appreciated.

Best regards,
ZM
  • You can have item-type dependent file naming conventions with ZotFile using wildcards: http://zotfile.com/#user-defined-wildcards
    But they require some technical know-how to set up

    I thought it was possible to rename linked files without moving with Zotfile with some setting, but I may be wrong on that one.
  • Thank you for the response. The wildcard info looks quite flexible, but unfortunately, I cannot use Zotfile for this purpose, as it will indeed move the files as well as re-name them. I just tested this behavior again. Does anyone know of a way to make Zotfile only re-name the file, without moving it into Zotero's database from its current location?

    Seems to be an ongoing problem:
    https://forums.zotero.org/discussion/68517/zotfile-renaming-linked-files-but-not-moving-them

    https://forums.zotero.org/discussion/35932/zotfile-renaming-attachments-without-moving-them

    Regardless, it would be great if Zotero itself included such customization of the re-naming format directly, in its own file re-naming capability. Ideally, if one could also specify either a global renaming format, or various renaming formats per item type (as in Zotfile).
  • (Also, as an aside, is it a bad idea to use double-quotation marks in the file names, as I do? I notice that Zotfile's custom string definitions seem to ignore double quotation marks, but will allow and use single quotation marks!)
  • Those threads you linked to are very old. If you set the Zotfile settings to use Zotero storage or to use linked field but leave the file location blank, it should rename the files in place, I believe.

    Generally, it’s a bad idea to use quotes of either kind in file names. I recommend against it.
  • Thank you, bwiernik.
    I had tried that solution recommended in a thread, of setting linked field blank, but still no luck. The file was still moved as well as re-named.

    What is the concern with quotes in file-names?
  • quotes are frequently used to delimit filenames or escape characters. While it's possible to work around that, whenever you use any tool that hasn't explicitly accounted for this, things will break; this is even more likely as you move between Mac and Windows.
  • Thank you again, adamsmith. Any suggestions on a good way to differentiate books from articles in the file names, without using quotes or other potentially rascally characters?
  • Underscores (to signal italics) around book names?
  • Perhaps, except those will get confusing if a file is renamed (manually or automatically) for systems that can't handle spaces, so spaces get replaced with underscores as well.

    Any recommendation on an authoritative up-to-date list / guideline on file-naming, especially of "forbidden" characters? I see various such online as I search just now, but they all seem to differ in the details. (Question marks and colons, which often appear in article titles, certainly can pose problems even for the Mac file system).
  • There's no authoritative list -- there are various lists depending on the level of robustness you're going for.
    US NIST I believe still recommends only (ascii) letters and numbers, hyphens and underscores, but that's more restrictive than necessary for most purposes. Definitely avoid colons, though.
  • Note that Zotero should automatically strip characters that aren't valid in filenames on all modern OSes. I don't know if ZotFile somehow goes around that, but it shouldn't. You should be able to test it easily by trying to include a colon.
  • edited April 16, 2020
    Good to know! I just did some tests with both Zotfile and Zotero's respective renaming commands. Indeed, both stripped out semi-colons and could not handle double-quote marks. Interestingly, both did allow single-quote marks...

    So maybe single-quote marks would be a good way I can still differentiate articles from books (i.e. putting quotes around article titles in file names, but not around book titles). Or I might give up on that differentiation, as it would still require manual re-naming...at least until Zotero might allow differing attachment naming string formats per item type. So meanwhile perhaps I should just use a single naming convention for all file types, which would allow me to use Zotero's renaming.

    Also, a feature request for the batch re-naming functionality:
    Zotfile allows selection of (one or multiple) top-level Zotero items (e.g. books, articles, etc.) and then applying its rename functions. Zotero itself seems to only allow selection of the PDF itself, within the top-level item, which is a bit more tedious as it requires opening up each item, selecting each PDF one by one. Perhaps Zotero could allow top-level selections of the items, and then the contextual menu would appear for the top-level items.
  • You could write a Zotfile wildcard that renames per item type (there is one for example below), but, honestly, I would say why bother? I don't know that this is a distinction you really need to make in the file name. That's something you could easily infer based on your knowledge of the titles or a quick preview/opening of the file.


    {
    "W": { "field": "title",
    "operations": [ { "function": "exec", "regex": "([^:.?!]+).+$", "group": 1 },
    { "function": "replace", "regex": "<i>|<\/i>|<b>|<\/b>|<sup>|<\/sup>|<sub>|<\/sub>|<span[^>]+>|<\/span>", "replacement": "", "flags": "g" },
    { "function": "replace", "regex": "[\\\/()~!@#$%^&*{«»„““”‘’|….,;`^<>'}+:?®©]*", "replacement": "", "flags": "g" } ] },
    "B": { "default": "publicationTitle",
    "artwork": "medium",
    "audioRecording": "medium",
    "bill": "code",
    "bookSection": { "field": "bookTitle",
    "operations": [ { "function": "exec", "regex": "(^.{0,30}).+$", "group": 1 } ] },
    "case": "court",
    "computerProgram": "itemType",
    "email": { "field": "itemType",
    "operations": [ { "function": "replace", "regex": "\\w+", "replacement": "Personal communication", "flags": "g" } ] },
    "hearing": "committee",
    "instantMessage": { "field": "itemType",
    "operations": [ { "function": "replace", "regex": "\\w+", "replacement": "Personal communication", "flags": "g" } ] },
    "interview": "itemType",
    "journalArticle": { "field": "journalAbbreviation",
    "operations": [ { "function": "replace", "regex": "\\.+", "replacement": "", "flags": "g" } ] },
    "letter": { "field": "itemType",
    "operations": [ { "function": "replace", "regex": "\\w+", "replacement": "Personal communication", "flags": "g" } ] },
    "manuscript": "type",
    "map": "type",
    "patent": "applicationNumber",
    "podcast": "itemType",
    "presentation": { "field": "extra",
    "operations": [ { "function": "exec", "regex": "Abbr: *(.*)", "group": 1} ] },
    "report": "type",
    "statute": "code",
    "thesis": { "field": "thesisType",
    "operations": [ { "function": "exec", "regex": "([^ ']+)", "group": 0 } ] },
    "videoRecording": "medium"
    },
    "Y": { "default": "issue",
    "patent": { "field": "filingDate",
    "operations": [ { "function": "exec", "regex": "([A-Z])[a-z ]?[^0-9]*([0-9]{4})$", "group": 2 } ] } },
    "S": { "default": "issue",
    "patent": { "field": "filingDate",
    "operations": [ { "function": "exec", "regex": "([A-Z])[a-z ]?[^0-9]*([0-9]{4})$", "group": 1 } ] } }
    }
  • bwiernik, thank you for this.
    It does seem more trouble than it's worth to script program such a system of variable names. I'll try to make peace with the idea of a single name format for all items.
  • Check attachmentRenameFormatString within Hidden preferences, you can play around a bit. I deleted the space before and after each dash and replaced the dash with an underscore. It works fine.
    https://www.zotero.org/support/preferences/hidden_preferences#translator_preferences
Sign In or Register to comment.