Extension to delete snapshots

This discussion was created from comments split from: Removing snapshots.
  • edited April 27, 2021
    You could try this extension (https://github.com/redleafnew/delitemwithatt) to remove the snapshots by selecting the items with snapshots and right clicking, choosing Delete Attachment(s)-Delete Snapshot(s) Only.
  • edited April 27, 2021
    @johnmy: Did you write this extension? If not, can you point the author to this thread?

    I would discourage people from using this extension in its current form. It's deleting files directly on disk, for no good reason. If someone wants to make an extension that moves snapshots to the trash, that's fine, but it shouldn't be deleting files on disk along with that. Zotero manages attachment files automatically. When the trash is emptied, the files will be deleted. Moving attachment items to the trash but then deleting the associated files directly so that they'd be missing if the items were restored from the trash makes no sense and breaks user expectations.
  • @dstillman, thanks for your kind reminder. Yes, I wrote this extension. I would like to move the attachment to trash (Windows trash or Zotero trash) before they were deleted from the disk, however I don't know which function should be used in the code, now the OS.File.remove was used. Is there a more proper function, and I would like to replace the improper one.
  • This extension was wrote to delete attachment simultaneously when a item was removed after zotfile was installed.
  • I tried this Zotero.Items.trashTx(id), however, after the zotero trash was empty, the attachment file still remains in the linked folder.
  • edited April 27, 2021
    Linked files aren't deleted by Zotero when the item is deleted, so deleting the file directly might be reasonable for that, but you'd want to do that only for linked-file attachments — item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE — and only if actually erasing the item, not moving it to the trash (where there's an expectation that the item can be restored to the library in its original state). And you'd want to warn the user clearly that you were going to delete the linked file, since that's not normal Zotero behavior and wouldn't be expected.

    For stored files, you should let Zotero handle it.

    Snapshots are always stored files, so deleting the file makes no sense for those.
  • thanks, I will consider to revise it.
  • @dstillman, thanks, the extension is updated as you suggest, only the linked file will be removed directly from the disk.
  • edited June 1, 2021
    Once I confirm to delete the file link, there is no way to restore the linked physical file itself. I know your intention is deleting linked file, but it would be better 'linked target physical files' just go to WINDOWS TRASHBIN first(I hope you could find the solution to this). It is quite dangerous possibility if linked files go unrecoverable with just a whim, given this extension is very likely used in bulk manipulation fashion.

    And it deletes 'URL Link' when you choose to 'delete Snapshot only'(like your amazon book URL link, not snapshot itself). I think it is clearly unintentional.
    * Fortunately, since these URL links can be recovered from Zotero Trash by search and selection, this second problem can be mitigated from user's side.

    Other than that, it seems useful and works as intended, thanks for your work.
  • @konstantine thanks for your testing, I tried to look for a javascript or a zotero function that throw the file to windows Trashbin when the linked file was removed, but failed.
Sign In or Register to comment.