Replacing deleted attachments in Zotero's storage folder
Hello
Due to a snafu having nothing to do with Zotero, I accidentally deleted most of the file attachments (e.g., pdf files) from my Zotero storage directory. The directory structure is still there (consisting of names like DHE5ASNE), or at least a great deal of it is. But the files are mostly gone. (Fortunately, the .sqlite Zotero database itself seems to be ok.)
I managed to recover many of the pdf files with deleted file recovery software. My questions are about how I might manage to put them back where Zotero .
First of all, is there an easy (or at least automated) way of finding which attachments are not where Zotero expects to find them, other than just clicking on every one of them?
Second, is there a smart way of getting files back into their original folders? (I'm comfortable scripting, if it makes a difference.)
Thanks a lot for any help!
Malcolm
Due to a snafu having nothing to do with Zotero, I accidentally deleted most of the file attachments (e.g., pdf files) from my Zotero storage directory. The directory structure is still there (consisting of names like DHE5ASNE), or at least a great deal of it is. But the files are mostly gone. (Fortunately, the .sqlite Zotero database itself seems to be ok.)
I managed to recover many of the pdf files with deleted file recovery software. My questions are about how I might manage to put them back where Zotero .
First of all, is there an easy (or at least automated) way of finding which attachments are not where Zotero expects to find them, other than just clicking on every one of them?
Second, is there a smart way of getting files back into their original folders? (I'm comfortable scripting, if it makes a difference.)
Thanks a lot for any help!
Malcolm
https://www.zotero.org/support/sorting You're saying you have the files with their original names, but not connected in any way with the folders they were in?
You could pretty easily write a Python or similar program to run an SQL query on zotero.sqlite (joining items and itemAttachments by itemID) to get the item key and filename for all attachments in your database with a path beginning with 'storage:', look for each filename in the temporary folder, and copy it to the associated storage directory if not already present.
Unfortunately, the files don't have their original names; rather they were renamed according to the title in their metadata by the file recovery program. It might still be possible to write a script that matches the titles in the Zotero database with these files but that depends on them having the same title in their metadata and in Zotero. There are only about 350 missing attachments, so I think it may be worth just adding them manually.
But you're at your file sync quota, so presumably you have a bunch of files that weren't uploaded because of that.