File renamed when link to it is set

This has been logged and reported as bug D958285293.
My Zotero version 5.0.37.

Since 2 days it happens that during setting a link from a database entry to a file on my computer the file is renamed!

Initial situation:
On my computer there is the file "Der-Grundstein-1916-027.pdf".

1. For the database entry
"Anonym: Ausdehnung der Frauenarbeit auf Bauten. Der Grundstein 29 (27) 1916. S. 149."
I open context menu Attach files | Attach link to file

2. I browse through my directories and select file "Der-Grundstein-1916-027.pdf".

In Zotero the link has the name "1916 - Ausdehnung der Frauenarbeit auf Bauten.pdf".
In the directory on my computer the file is renamed to "1916 - Ausdehnung der Frauenarbeit auf Bauten.pdf".

This has worked for years. I have a big problem with this. Please help.
  • You can disable automatic file renaming in the General pane of the Zotero preferences.

    @dstillman Should linked files be automatically renamed? I'm not sure I would expect that as a user (but can see the argument either way).
  • Thank you. That was the problem.
    It did not occur to me that this is a setting and that a Zotero update would change something like that.
    Changed it, and it works as desired.
  • Yeah, I'm not sure I like that Zotero does anything to linked files and I'm wondering if that was an unintended consequence of how auto-rename was implented --
    renaming linked files seems inconsistent to me. Zotero doesn't delete linked files when you delete them; I don't think it should rename them, either. E.g. you may have other software pointed to the same file and this would break things.
  • It was intentional (and is mentioned in the blog post). The ultimate goal here is to absorb some of the more popular ZotFile's functionality, which would include managing filenames for linked files (though I'm not sure whether ZotFile does automatic renaming for existing linked files that you add to Zotero).
  • I'm not sure whether ZotFile does automatic renaming for existing linked files that you add to Zotero
    it doesn't, no. Only where you specifically ask it to or where it moves the file
  • Yeah, so the behavior here makes me a little uncomfortable — we obviously don't delete or sync linked files — but the reason for it is that we're planning to add continuous renaming, where the filename is kept up to date as you modify the parent metadata or change the renaming format, in a future version. Since we're hoping to take over some of the ZotFile functionality, the idea was that that would apply to linked files as well, and so the auto-renaming behavior and pref kind of needed to do the same (because this pref will just change to "Keep attachment files named using parent metadata" or something similar).

    People with linked files obviously might not want their files renamed, but I'm not sure how many of those people want any of their files renamed, so they might just want to turn off the pref.

    It seems the OP's issue was mainly that they didn't know about the addition of auto-renaming at all, but that's separate from whether the behavior makes sense, and part of the reason we wrote a blog post for this release.
  • edited March 15, 2018
    (Perhaps the broader discussion should be moved to a new thread?)

    I can think of a variety of use cases for mixing stored and linked attachments, some of which automatic renaming makes sense and others where it doesn't. For example, if an attachment is linked because it is very large, has sensitive data, or is synced using Dropbox/similar, then automatic renaming makes sense. If a file is linked because it is being used by another program (e.g., I sometimes add links to analysis scripts or data files to Zotero items), then automatic renaming isn't desired (though in my case I still want all of my stored files to be renamed).

    Two options I can think of:
    1. Change the automatic renaming pref from a checkbox to a dropdown with the options: All files, Stored (not linked) files, No files.
    2. Give the option to disable automatic renaming for specific files (e.g., a different keyboard shortcut for dragging, a checkbox in the file picker, a checkbox in the right pane when the attachment item is selected).

    Either (or both) of these would increase the flexibility without adding too much complexity, I think.
  • This is an old thread but I've just realised (too late) that this still happens after linking Zotero to my 1000+ saved pdfs.

    I don't really mind the naming style as such, but it does mean that I've just broken every single hyperlink I have to those files in Word, Evernote etc. I use hyperlinks to my files quite extensively to save time linking between them so this is quite annoying.

    I even went through all the preferences beforehand to make sure that I wasn't going to mess anything up - but the checkbox bwiernik mentions is to "automatically name attachment files", not linked files.

    +1 for this kind of behaviour being unexpected and unacceptable, in my view - fine for attachments but not for links, as Zotero may not be the only program linked to each file!
  • the checkbox bwiernik mentions is to "automatically name attachment files", not linked files
    Sorry for the trouble, but just to be clear, linked files are still attachments, so the pref text isn't a mistake. (And, e.g., the base-dir setting in Advanced is called "Linked Attachment Base Directory".)
  • Ah ok, thanks for clarifying
  • Just had this happen. All my linked files were respecting my specific fine naming. Update, and it has been renaming them without me noticing for the last week. What kind of insane default setting is that? Thankfully it is only about 10 links at this point, but I find that having this option set as a default is a very, very strange decision.
  • What kind of insane default setting is that?
    I explain the reasoning for it above, so there's no need to wonder. We intend to add continuous renaming and adopt ZotFile-style renaming rules, and since ZotFile is aimed primarily at linked files, we applied automatic renaming — which is the first step towards continuous renaming — to linked files as well. As bwiernik notes, it's likely the desired behavior for many use cases of linked files.

    The auto-renaming also applies only to PDFs by default, and it applies only to the first file you drag to an item, so it doesn't rename, say, a data file, or even a supplementary PDF that you attach to an item that already has a PDF.

    (Also, to be clear, this was implemented a year ago, so it's not new, though you may have been using an outdated version until recently.)

    But I agree that it's better to make this explicit, so in the latest Zotero beta I've added an additional "Rename linked files" preference, defaulting to off, below the original pref. People currently relying on the auto-renaming for linked files will need to enable it from the preferences.
  • I do hope this change makes its way to the release version of Zotero soon. This splitting of preferences is absolutely needed. I, for example, have a custom of making multiple entries for book chapters in edited books, but I prefer to have the whole book in a single file and then link all of the chapters to this one pdf file. I simply can't do this with this renaming of the linked files on, because with each new added link the rest of the links gets broken.
  • For that use case, I recommend you handle the linking in Zotero—create a Book item for the whole book with the PDF link and then connect each chapter item to the book item as a Related Item.
  • That is the intelligent way to handle this, but I prefer to just double click an item and hope for the best. ;) Honestly, what is intelligent is not always the most efficient. One of the huge advantages of working with Zotero is having instant access to whatever book or article you need to refer to at the moment. Linking would mean that I would first have to click an item, then access the tab with the related items to see if there is an entry suggesting that I may already have the pdf for it (no way I'm going to remember it every time), then I would need to access the book item, open the pdf and go back to the chapter entry to create a note where I would write whatever I need to note. All of these steps are unneccessary. I can just link the pdf file containing the book (which is already in the Zotero database). Double click, scroll to the chapter (while glimpsing at other chapters that may be useful), create a note and off to work.
  • The "Rename linked files" preference is now available in Zotero 5.0.61.
  • This is great, thank you!
Sign In or Register to comment.