Change path of all "link to file..." citations in library

Hi all,

I have a library that I built around links to files in a Bibliography/ folder on a Linux system. I had to migrate that machine to Windows, and now that folder cannot have the same path as before as the paths' structure has obviously changed.

Is there a way I can automatically relink all entries to the new path? Any batch-editing tools won't do as the link's paths are obviously all different. Ideally, I would need low-level access to Zotero's database and change all entries with a wildcard set on the original path. I don't mind doing it with SQL or any programming language, but I could do with a tip on how to do it without reading much of Zotero's developer docs!

Is it possible to do it within Zotero? If not, can a good soul point me to Zotero's guts on my machine (a SQLite file, a MySQL instance, whatever it is in practice) so I can do my dirty fix? Thanks so much,

Andrea
  • Hi @dstillman,

    Thanks very much for the link. That's definitely the way to go for the future (and in retrospective, what I should have used from the start), but that won't change the existing absolute paths.

    I found the SQLite file where the Zotero libraries are likely stored... is that my only option? Thanks,

    Andrea
  • edited January 5, 2023
    Set the linked attachment base directory you want to use on this computer and then try to open a file with an absolute path. It should auto-detect all your missing files and offer to relink them.

    Do not edit the database directly. All changes have to be made through the application.
  • I've re-linked a few files manually but I could see no auto-detection and definitely no files have been done automatically. The workflow is what I expected (and dreaded): I try to open a file, the file is flagged as missing and I have an option to relink manually, which defaults to the top level of my home directory every time.

    Let me know if there's any way I can help if this is supposed to be a feature, e.g. by flagging this as a bug.
  • What version of Zotero are you using? This was added in 6.0.16 in October.

    Did you actually set the linked attachment base directory to a containing folder of the current location of the files?

    Can you provide a Debug ID for attempting to open a missing file?
  • edited January 5, 2023
    > What version of Zotero are you using? This was added in 6.0.16 in October.

    6.0.19 just downloaded and installed yesterday.

    > Did you actually set the linked attachment base directory to a containing folder of the current location of the files?

    All my files are supposed to be at the top level of my Link Attachment Base Directory. Every time I relink a file manually, the output is a relative path to that LABD, as expected. So, if before I had /home/$me$/path/to/Bibliography/mypaper.pdf, after relinking to C:\Users\$me$\path\to\Bibliography\mypaper.pdf, the new path in Zotero appears as "mypaper.pdf".

    > Can you provide a Debug ID for attempting to open a missing file?

    Here it is: D161233840

    Thank you!
  • OK, thanks. It looks like there's a bug in the auto-detection feature when moving from macOS/Linux to Windows — it's supposed to normalize the slashes, but that doesn't seem to be working properly in this direction.

    We can probably fix this later today in the beta.

    If you don't want to wait, you can use the third-party Zutilo plugin to batch-change the paths.
  • Thanks for taking this up.

    Ironically, I have the same problem with the Python libraries I wrote for my research, which now kick and moan due to changes in the path and file handling (you would think that using os.path.join() would make your code cross platform? I thought so too! :D)

    In short, I can wait. There's all that to fix first.

    Many many thanks!!!
  • This should now be fixed in the latest Zotero beta.
  • Hi dstillman, sorry for the slow reply. Just tested 6.0.19-beta.14+9d2c7d44f and it worked like a charm! Thank you so much.
Sign In or Register to comment.