Zotfile: Can't effectively change the directory for saving files

Hi all,

I've recently re-installed Zotero on a new laptop and wanted to use Zotfile for storing files on Google Drive. Before that, I used WebDAV with my old university cloud.

It all worked well, the files were all copied to the Google Drive. However, I then re-assigned the drive letter from G to Z and also changed the directory accordingly. But for some reason, the path on drive G is still associated with the Zotero entries, changing it in the Zotfile options doesn't do it. The effect is that I can't access any of me PDFs right now. I tried everything: re-installing Zotero and Zotfile, deleting the profiles. The problem is that switching back to the WebDAV solution doesn't work. All PDFs have the chain symbol now, which was the effect of Zotfile as I understood. But weirdly, this is also the case when I re-install Zotero without Zotfile, it's still there. It seems like the file is permanently associated with the link that doesn't exist. What can I do?!

  • Which directory did you change when you changed drive letters? You'd have had to change the base directory in the Zotero preferences (advanced --> Files and Folders) in addition to the one in the ZotFile preferences.

    If you never had a base directory set, I believe your only option now is to use the Zutilo add-on to batch change file links. Make sure you have a good back-up of your database -- this *can* go disastrously wrong with minor typos/mistakes.

    Generally, this is why we recommend against linked file set ups. They're fragile and error prone, especially if you don't have a precise understanding of how linked files work in Zotero (which you shouldn't need to have).
  • If you never had a base directory set, I believe your only option now is to use the Zutilo add-on to batch change file links.
    No, Zotero will now try to relink all missing linked files within the selected base directory when you try to open one.

    (But linked files are still fragile and error prone!)
  • Thanks, I had missed that. So to make sure I understand how this works now, say the above files are stored as
    G:/Documents/Zotero-files in Zotero and are actually in Z:/Documents/Zotero-files
    setting the linked basement directory to Z:/Documents or Z:/Documents/Zotero-files would try (likely successfully) to relink them?
  • edited August 3, 2023
    Yes. When you tried to open the file, it wouldn't be found in G:, Zotero would check within the current base directory in Z:, it would iteratively check parts of the path (starting with the full path minus the drive letter, if I recall), and when it found the file, it would ask if you wanted to relink all files, after which it would convert them to relative paths.
  • edited August 4, 2023
    I recently went through a similar process and it went smoothly. When I added the Linked Attachment Base Directory setting, all linked PDF files were successfully transitioned from absolute to relative paths by Zotero.

    The first thing to know is that the Zotfile 'Custom Location' is where linked PDFs are *stored*; but not necessarily where Zotero *looks* for each linked PDF when you want to open it. That depends on whether you have a setting for Linked Attachment Base Directory in Zotero preferences.

    If you do *not* have a Linked Attachment Base Directory set there, that full storage path that Zotfile used to store the PDF is baked into the linked file's location in the Zotero sqlite database, eg G:\ZoteroAttachments\filename.pdf. That is an 'absolute' path. And that full path is where Zotero looks for the linked PDF file when you try to open it.

    If however you *do* have a Linked Attachment Base Directory set, that is where Zotero looks for the linked PDF. In the Zotero sqlite database, the above absolute path G:\ZoteroAttachments\filename.pdf is changed by Zotero to attachments:filename.pdf when the LABD setting is first added. That's a 'relative' path.

    So there is not necessarily a *need* to set a Linked Attachment Base Directory in Zotero preferences for linked PDFs - it depends on your setup.

    Absolute-path linked PDF attachments work fine if your linked PDFs are at the same absolute original storage path (eg G:\ZoteroAttachments\filename.pdf) on each computer where you use Zotero. Or if you only use Zotero on one computer. There are presumably also particular user scenarios where linked PDF are stored at various *different* locations on a given computer, where you would wish to preserve those absolute paths in order for those PDFs to be found/opened by Zotero.

    On the other hand, relative-path linked PDF attachments (ie with a Linked Attachment Base Directory setting) allow you to have your linked PDFs stored at a different path on different computers. Or to easily change their storage path on a single computer and have them still found by Zotero. However should you ever wish to revert back to absolute from relative paths, the specification of each original absolute path for each PDF has been removed from the sqlite database; [edited:] so a complete reversion may not always be possible (unless I'm missing something).
  • However should you ever wish to revert back to absolute from relative paths, the specification of each original absolute path for each PDF has been removed from the sqlite database; so an exact reversion is not possible (unless I'm missing something)
    Not sure what you mean by that. It just reverts the attachments to the absolute paths the files are currently at within your base directory.
  • OK, we're probably dealing with unusual scenarios here. But in writing the above it occurred to me that it may not always be possible to fully revert to what you had originally in all cases, after setting a LABD for the first time. Let's say your scenario is similar to the OP's. You move all your linked PDFs into a new, single folder location, and then set a LABD. The linked files may have previously been in another, single folder, or in many different folders (eg with different parent drives or parent folders); with all those full 'absolute' paths explicitly stored, file by file, in the Zotero database (in the itemAttachments table). After the LABD setting, Zotero then is able to find the linked PDFs at the new folder location, so all is well. But it has now placed 'attachments:' as the file location prefix in front of each filename in the itemAttachments table, in place of the previous full explicit ('absolute') paths to each linked PDF. So if you later decide that you want to revert to have your linked PDFs stored where they were previously, Zotero no longer 'knows' those locations. If it's just a single, *different* folder location for *all* your linked PDFs that you want to revert to, then you could presumably just move the files, then set a new LABD (the new folder), and then finally revert to absolute paths. From what you said I assume Zotero would then rewrite full paths to itemAttachments, replacing the 'attachments:' prefix with those full paths (to the new LABD location). So that is 'reversion', just with some extra steps. If however your linked PDFs had originally been spread across a range of different folders, I can't see any easy way to revert to that setup after a LABD setting. You would have had to save all those paths somehow prior to the first LABD setting, and then re-do each link manually or in code.

    In any case I have edited my original post to say "a complete reversion may not always be possible". Again ... unless I've missed something.

    And let's not make Zotfile/linked files sound harder than they are. Zotfile/linked PDF files just 'work' for most people who use them. ;)

  • edited December 2, 2023
    Thank you @tim820, you just saved my life!
Sign In or Register to comment.