Zotfile does not delete PDF files when a database entry is deleted
Hi,
I have zotfile set with a custom location for the PDFs.
I've noticed that zotfile won't delete the PDFs after moving an entry to trash in zotero, not even after emptying the trash.
Essentially unwanted files just accumulate in my PDf folder without ever being removed automatically.
Is this a known bug?
Any workarounds?
Thanks!
I have zotfile set with a custom location for the PDFs.
I've noticed that zotfile won't delete the PDFs after moving an entry to trash in zotero, not even after emptying the trash.
Essentially unwanted files just accumulate in my PDf folder without ever being removed automatically.
Is this a known bug?
Any workarounds?
Thanks!
I think maybe that answers your other question as well?
Without zotfile, adding an entry to the DB creates a subfolder under `storage` with some obscure code and in it the pdf file is stored. Deleting the entry makes zotero delete the subfolder.
Using zotfile, the subfolder is created but the pdf is subsequently moved to the custom storage location and the subfolder is left *empty* (i.e. no link is formed). Deleting the entry in zotero has no effect on the pdf file in the custom location.
This seems to me like bugs in zotfile, no?!
https://www.zotero.org/support/attaching_files#file_copies_and_links
Did I get you right?
There's, however, an open ticket in ZotFile that would allow you to get this or similar functionality. Absent 3rd party work, it's not likely to get implemented, though:
https://github.com/jlegewie/zotfile/issues/96
You're absolutely right that typically targets should not be deleted when links are, but in this case there are oblivious problems created.
Thanks for the link on the ticket, I hope at least someone will come up with a workaround...
Clean up by changing the custom location of files, and the 'clutter' remains behind. As follows:
1) Create new custom folder:
Tools --> Extensions --> Zotfile Settings --> Change 'Location of Files' --> Create and select new folder (I named it with a date tag)
2) Copy Zotero library to new custom folder:
Select all entries in 'My library' (e.g. CTRL+A) --> right click for menu --> Manage attachments --> Rename Attachements --> Accept 'Do you want to move and rename attachments?"
3) Double check and delete/archive the outdated Zotfile folder
I've just installed Zotero+Zotfile, but this seems to be working (had to migrate a bunch of refs)
Cheers!
This is important for one who want to access research papers with other tools like devonthink, spotlight, ...
zotfile is a ugly workaround.
Check it out at https://github.com/j718/zotero-sync
1. First it is assumed nothing important is lying in :Unfiled Items: to begin with.
2. A new collection titled :DELETE: is created.
3. Zotfile is needed to rename & relocate the linked attachments via a subfolder scheme defined by :%c: (This could be done/ changed temporarily just as well for this purpose).
4. The item to be deleted is removed from its parent collection, and now comes to lie in :Unfiled Items:.
5. Once in a while all items in :Unfiled Items: are moved to the :DELETE: collection, followed by a Zotfile rename command that relocates the linked files to the :DELETE: folder within the Zotero storage directory.
6. The items are now moved to the bin & deleted permanently.
7. Once items are deleted from Zotero, their defunct attachments are similarly wiped out from the :DELETE: folder.
8. The Zotfile rename preferences maybe changed/ removed as before
Thanks to the devs for an amazing piece of work! Thanks also to the lively Zotero community!!
I'm on linux:
- File -> export library (with export files option) to any dir. Say ~/A.
- Copy all files to a directory:
cd ~/A && mkdir pdfs
find files/ -type f -exec cp '{}' pdfs/ \;
- List the files to delete:
rsync -van --delete pdfs/ zotfile-dir/
- If this list of files is correct, delete them by removing the -n
This only works if, like me, you have all pdf managed by zotfile all dumped in a dir.
This is just an idea. Modify as you need.
@j718 I prefer to manually watch what is to delete, but thanks. Nice work!
Then I can periodically filter for that Tag, bulk "Convert Linked Files to Stored Files", then select all and Move to Trash, and empty trash.
This seems pretty smooth and doesn't need to use any fancy scripts or anything.
1.- Set a new custom folder in zotfile preferences and rename all attachments.
2.- Erase all files in the old custom folder
3.- Set the old custom folder in zotfile preferences and rename all attachments (optional).
Code: https://github.com/redleafnew/zotero-javascripts/blob/main/04delete-the-attachment-files-after-the-items-have-been-removed-when-zotfile-was-installed.js
Just comment the following line to test the behavior:
await OS.File.remove(FullPath); //删除文件
Source: https://zhuanlan.zhihu.com/p/356071795 (Chinese)
https://github.com/redleafnew/delitemwithatt