opening/retrieving and saving linked files

edited February 2, 2022
I recently switched to a new laptop, and have set up Zotero on it.

However, I cannot open/retrieve PDF files that I had previously added (as a linked file - using OneDrive cloud storage) while using my old laptop.

Instead, I get an error message called File Not Found and it says "The attached file could not be found at the following path: [PATH]. It may have been moved or deleted outside of Zotero or a Linked Attachment Base Directory may be set incorrectly on one of your computers."

After seeing this message, I corrected my Base Directory path via Preferences > Advanced > Files and Folders so that it is set to the OneDrive folder in which my Zotero files are stored (the same OneDrive folder I was using on my old laptop). I restarted Zotero and tried opening the PDF again. No luck.

Can you help?
  • If you didn't set a relative link folder on your old laptop, you'll first need to fix your links. Zutilo can help you with that: https://github.com/wshanks/Zutilo though make sure to test the bulk change link function before using it on hundreds of entries.
  • edited February 2, 2022
    Thank you.

    ------

    As suggested, I added the Zutilo plug-in and tried using the "Modify attachment paths" feature to fix my links. As my old laptop was Windows and my current one is a Mac, I checked the box "replace all instances" so that I can switch from \ to /. To be more specific, my old partial path is "C:\Users\trcmlw\OneDrive\Literature\In Zotero\" and my new partial path is "/Users/trcmlw/Library/CloudStorage/OneDrive/Literature/In Zotero.

    After doing this, I tried opening the PDF again and it still does not work. I get the same error message (the one I mentioned above) but this time with my new path. The other thing thats different is when I click on "Show attachment paths" from the Zutilo item menu, the path says "attachments:FILENAME" instead of the actual path.

    What am I doing wrong? Everything I've done above is following the Zutilo Command Reference.

    ------

    Also, the Zutilo Usage Notes says "This function (referring to "Modify attachment paths") is mainly useful for when you change computers or hard drives and break the links to all of your attachments (though note that Zotero has a relative attachment path feature that should address this issue for attachment collections all stored together under one parent directory)."

    It specifically states that I should have been able to fix my issue by changing my Linked Attachment Base Directory (my original question).

    Why is changing my Linked Attachment Base Directory not working for me?


  • I get the same error message (the one I mentioned above) but this time with my new path.
    You're saying you get an error message that the file can't be found at the path even though it's the right path? Have you checked the filename? I.e. is the filename that Zutilo/Zotero show you the same as in the folder?

    (Zutilo shows attachments:FILENAME because of the relative link, so that sounds like it's working as it should).

    And for the second part of your question, as I said in my original response, you could have solved the issue with relative paths if you had also set them on the original machine which it doesn't sound like you did.
    It may also be possible to just switch the relative paths in Zotero, i.e. start with the old one, then move to the new one, but I'm less confident about that option & think Zutilo is cleaner in those cases.
  • Ok I've found the issue (for why the file cant be found at the new [correct] path). This is what is happening:

    1. The incorrect path that I need to fix is "INCORRECT PATH\Smith et al2019\title.pdf"

    2. After modifying the attachment path via Zutilo, the modified correct path becomes "CORRECT PATH\mith et al2019/title.pdf"

    Note that, in the modified correct path, the subfolder name (in my case, author last name and year = Smith et al 2019) has its first character cut off.

    Why is this happening and how do I stop this from happening?
  • That issue has been reported before https://forums.zotero.org/discussion/comment/359832/#Comment_359832 but I'm unable to replicate it in any way. Could you give use the exact strings and settings you've been running? I'd like the first and last letters of each substring included if possible, everything else you can xxx out if you want (or not, this isn't a security concern, only a privacy issue)
  • @qqbb I saw you tried to troubleshoot this before -- did you ever get anywhere?
  • edited February 3, 2022
    Yup, I can provide more detail - but any chance I can do a screenshare with you? Might be easier to go through this together, in real time.
  • As requested,...


    Settings

    *Zotero Preferences
    - General: everything checked except "Rename linked files"
    - Sync: everything checked except "Sync attachment files in My Library using []"
    - Advanced>Files and Folders: base directory set to "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero"

    *Zotfile Preferences
    - General Settings>Location of Files: custom location set to "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero" (use subfolder defined by [] is UNCHECKED)
    - Renaming Rules>Renaming Format: {%a.,}{%y-}{%t}
    - Renaming Rules>Additional Settings: checked boxes are "truncate title...", "maximum length...", "maximum number of authors...", and "add suffix when..."

    ----

    What I Did

    1. clicked on reference to open PDF and I get an error message that says "The attached file could not be found at the following path: C:\Users\z5177140\OneDrive - UNSW\Literature\In Zotero\AndrewsG et al2012\Andrews et al., 2012-Moving beyond walkability - On the potential of health geography.pdf"

    2. right clicked on reference, went to Zutilo item menu, clicked on "Modify attachment paths"

    3. entered the following for Old Partial Path: "C:\Users\z5177140\OneDrive - UNSW\Literature\In Zotero\" and checked the box for "Replace all instances of partial path string"

    4. entered the following for New Partial Path: "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero"

    5. clicked on reference to open PDF and I get an error message that says "The attached file could not be found at the following path: /Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero/ndrewsG et al2012/Andrews et al., 2012-Moving beyond walkability - On the potential of health geography.pdf"

    Here, you can see that, in the modified correct path, the subfolder name (in my case, author last name and year = AndrewsG et al2012) has its first character cut off.
  • Because I have subfolders titled with the author last name and year, im guessing that on my old laptop, I had "use subfolder defined by []" box checked in the Zotfile Preferences> General Settings>Location of Files
  • Thanks -- I'll spend some time investigating.
  • I saw you tried to troubleshoot this before -- did you ever get anywhere?
    @adamsmith: No, I wasn't able to reproduce the issue. But so far nobody provided clear steps to reproduce it. This looks promising.
    What I Did
    @trcmlw: Thanks a lot for the clear steps! I tried to reproduce this on Windows and Linux, but I'm getting

    "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In ZoteroAndrewsG et al2012\Andrews et al., 2012-Moving beyond walkability - On the potential of health geography.pdf"

    on both systems. Note the missing path separator after "In Zotero", which is expected given that it's missing in step 4. The result is also mixing \ and / as expected.

    Just to be sure, could you check if you can reproduce the issue on another attachment? Could you please also paste the output of the "Show attachment paths" function as explained here? Also note the information on backups given there.

    Are you using a standard Zotero installation? Do you get the same issue if you do not check "Replace all instances of partial path string"?
  • Finally, I was able to reproduce the issue. In my test above on a Linux setup, the Linked Attachment Base Directory wasn't set. I was repeating the steps below "What I Did". There wasn't any issue. After setting the Linked Attachment Base Directory preference as well on Linux, I was able to reproduce the issue. Zutilo's "Show attachment paths" is giving

    "attachments:ndrewsG et al2012\Andrews et al., 2012-Moving beyond walkability - On the potential of health geography.pdf"

    @trcmlw: For now you should be able to avoid the issue if you clear the Linked Attachment Base Directory setting. Use absolute paths while fixing the paths. You can switch to relative paths when you're done using "Modify attachment paths". I would also recommend replacing all \ with /.

    I opened this issue on GitHub to track this: https://github.com/wshanks/Zutilo/issues/214
  • Thanks so much for looking at this! I was going to try with base directory set as my next try, too.
  • edited February 5, 2022
    Thank you!

    Still not working...

    1. I reverted to absolute paths
    2. Went through steps 2-4 again, but this time with a path separator at the end of the new partial path in step 4 (thanks for catching that omission)

    When I clicked on the reference to open the PDF, I get an error message saying the attached file could not be found at the following path: "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero/ForsythA et al2011\Forsyth et al., 2011-Urban Design - Is there a Distinctive View from the Bicycle.pdf"

    So while my original issue (subfolder name in the modified correct path has its first character cut off) is no longer there, the result is mixing \ and /.
    Basically, I am finding what @qqbb found in the first message. What now?

    @qqbb, in your second message, you recommend replacing all \ with /. How do I do that? The "replace all instances" box is already checked.

    And yes, the issue is reproduced on another reference/attachment, whether the "replace all instances" box is checked or not (i tried one with, one without). And yes, I am using a standard Zotero installation.
  • Forgot to add, Zutilo's "Show attachment paths" is giving "/Users/tml/Library/CloudStorage/OneDrive-UNSW/Literature/In Zotero/ForsythA et al2011\Forsyth et al., 2011-Urban Design - Is there a Distinctive View from the Bicycle.pdf"
  • edited February 5, 2022
    I am on MacOS FYI.
  • you recommend replacing all \ with /. How do I do that?
    @trcmlw: Use \ as your old partial path and / as your new partial path and check "replace all instances".

    See also Zutilo's command reference and this discussion for an explanation of the "Modify attachment paths" function. If "replace all instances" isn't checked, only the beginning of the path will be replaced. With "replace all instances" checked, you can replace multiple occurrences of a character sequence within a path, e.g., all backslashes.

    If you experience further issues, I would recommend using "Show attachment paths" on a linked file attachment that is working. See if its path looks any different. You could also use the complete result of "Show attachment paths" on a broken attachment as your old partial path and its complete correct path as the new partial path.
  • edited February 6, 2022
    @qqbb As mentioned in my previous message, the "replace all instances" box is already checked. And yet the issue remains.

    I pasted the output of "Show attachment paths" in my previous message.

    Your recommendation to use "show attachment paths" on a linked file attachment that is working is not doable b/c nothing is working.
  • the "replace all instances" box is already checked
    Yes, but did you enter a single \ character in the first prompt and / in the second prompt?
    Your recommendation to use "show attachment paths" on a linked file attachment that is working is not doable b/c nothing is working.
    Use the Attachment menu and select "Attach Link to File..." to create a new linked file attachment.
  • Yes, I did enter a single \ character in the first prompt and / in the second prompt.

    I clicked "Attach Link to File..." from the Attachment menu and created a new linked file attachment. It works and the path looks as it should, i.e., all the path separators are in the correct direction and no characters are cut off from the subfolder names.

    So while I could do that, or do your other suggestion to "You could also use the complete result of "Show attachment paths" on a broken attachment as your old partial path and its complete correct path as the new partial path", I would have to do it manually for every single reference. The point of me using Zutilo's Modify Attachment Paths function is to do it in bulk.

    Are you saying there is no way to do it in bulk given the issues I've encountered?


  • I'm not sure what kind of problem you're experiencing.

    Could you select a couple of broken linked file attachments, use Zutilo's "Copy(!) attachment paths", and paste the result here? Then please explain what's wrong about these paths. Is it simply a single \ that should be a / or are there any other issues?

    In general, batch modification should work. "Modify attachment paths" will replace one character sequence in your paths with another character sequence. You can use paths that are working as a reference.
Sign In or Register to comment.