Deleting files on disk when removing attachments

  • I tried delitemwithatt, and it removes the attachment in Zotero but the files remain on the harddrive. That defeats the purpose of this plugin.
  • edited November 15, 2022
    I have been using that Delitem add-on for some months to delete linked PDFs (using right click Delete Attachments), and my experience has been that it works for me.

    To confirm, I just checked all the linked PDFs in my Zotero Bin/trash that I had deleted, and they're all gone from my hard drive, as expected (ie right click Show File returns 'The attached file could not be found at the following path ...') [note that this is different to normal Zotero behaviour with files in the Bin, which remain on desk until the Bin is emptied]. I noted that in some cases I had just deleted a single PDF of several under an item, deliberately leaving the item itself with snapshots and other PDFs. However the listing in the Bin shows the whole item, but only the PDF I had selected had actually been deleted (as intended) while everything else remains.
  • @tim820, thanks for the quick feedback. I open an issue ticket with Delitemwithatt, https://github.com/redleafnew/delitemwithatt/issues/13 . It turns out that deleting attached folders are not currently supported. Zotero creates those folders for HTML attachments, containing multiple files. I really would like to batch delete all items with HTML folders. (I am setting up a sync folder solution on Onedrirve, according to Zotero instructions of splitting the database and attached files. However, having a myriad of tiny files is creating issues for OneDrive)
  • edited November 15, 2022
    Zotero creates those folders for HTML attachments, containing multiple files.
    @adeldaoud: I'm not sure what you mean by this, but I think it's some sort of confusion.

    First, Zotero has created single HTML files for web snapshots for a couple years now.

    And then this thread is specifically about linked files. The only folders that Zotero creates are for stored files within the Zotero data directory, and Zotero manages those folders automatically, including deleting them when the attachment is emptied from the Zotero trash.

    If you're talking about saved webpages with multiple files created outside of Zotero (e.g., with your browser) and added as linked files, then OK, but 1) Zotero isn't creating those folders and 2) you'll get better results using Zotero's own snapshot saving.
  • @dstillman, thanks for your input. The attached files I am refering to are in my case folders, and most likely created from earlier versions of Zotero. I am been using Zotero for many years. Yet I am not exactly sure if I created these files or Zotero created them. Nonetheless, they are there, and I would like to batch delete these folder attachments from my harddrive. In the future, I will be only using snapshost as you suggested. Do you have a tip on how to batch-remove these folder attachments?
  • edited November 15, 2022
    No, you're still misunderstanding. The only folders Zotero has ever created are the folders in the 'storage' folder — it just creates one folder per attachment, no matter what is in it. Previous snapshots happened to use multiple files, but that doesn't really have much to do with anything — they were still within 'storage' folders. And if you're talking about 'storage' folders, those are handled by Zotero itself, and you don't need a plugin for that.

    If you're talking about folders elsewhere on your computer, with an HTML file added as a linked file in Zotero, Zotero didn't create those. If those are what you're trying to delete, you'll need the plugin, because Zotero doesn't delete linked files, but we can't help with that.

    I'm just responding to your "Zotero creates those folders" comment and making sure you actually understand that folders within 'storage' are handled by Zotero.
  • Regarding "And if you're talking about 'storage' folders, those are handled by Zotero itself, and you don't need a plugin for that"

    Yes, the files I am referring to live in the storage folder, with multiple files. But so how do I delete multiple folders for multiple Zotero items in batch? When I select and right click those Zotero items, there is no option to "Remove Attachments" or similar.
  • edited November 15, 2022
    Right, so that's a totally different question — the thread you posted to was about linked files. Moving this to a new thread.

    As I've said, Zotero manages the folders in 'storage' for you. When you empty the trash, the associated files and folders for purged attachments are removed automatically. Nothing is deleted from disk while the attachments are just in the Zotero trash.

    If you're just asking how to select attachment items in Zotero in batch, you can do a search for "snapshot" in All Fields & Tags mode or try to create a saved search that matches the attachments you want to delete, do a Select All, and move the attachments to the trash, and then empty the trash.

    None of this has anything to do with the folders on disk, which, again, Zotero manages for you. (You should post to or close that GitHub thread, because the developer also misunderstood what you were asking.)
  • And if you're asking about orphaned folders in 'storage' — where the attachments have been removed completely from Zotero, including from the trash, but the folders were somehow left behind on disk (e.g., due to some bug in the past, or crashing during an operation), I think there's some plugin or tool that will scan the folder for orphaned files, but I would recommend just not worrying about it. Zotero will likely gain the ability to clean up orphaned folders at some point. Generally it's taken care of for you.
Sign In or Register to comment.