Remove unused attachments

Recently testing Obsidian and came here for this. Couple of thoughts:

  1. For removing previously orphaned files, I think the plugin is fine.
  2. Upon note deletion, removal of orphaned attachments should absolutely be core functionality.
4 Likes

Fully agree with everyone that believes removal of attachments should be done automatically upon deleting the note its attached too.

5 Likes

I’d also wish to have such a feature.
It would be really usefull, when there’s a popup window when deleting a note, so one can decide whether to delete the attachment, too.

2 Likes

Please add this feature.

The feature is a must.

Useful idea

Yes this needs to be implemented

Huh. I thought that dataview couldn’t list pages that were not Markdown: List other filetypes in vault · Issue #234 · blacksmithgu/obsidian-dataview · GitHub

So how can f.name.endsWith("excalidraw") this ever work? Or maybe this somehow works for *.excalidraw but not *.pdf?

1 Like

Hi everyone! Has this just been dropped suddenly? Or is it implemented and I have not found it? I am only starting with Obsidian now, but can already tell that my attachments folder will be a huge mess if this is not available. Specifically when dragging a lot of screenshots into the notes, that usually do not have names suggesting their content.

1 Like

This is an open feature request.

Above, you’ll see a workaround using a plugin. (I haven’t tested it personally.) Remove unused attachments - #7 by Vinadon

4 Likes

Thanks for the quick reply! @rigmarole I’ll check out the third party plugin then.

There’s also a new plugin called Janitor that does this (and other things)

6 Likes

I’ll check on the suggested plugins after I made progress on post import cleanup from Evernote.

My attachments folder currently has over 18k files in it. After I remove notes that whose only content was an attachment (think, pdf document) , I’ll run a plugin and see how many it cleans up.

This feature works be a great core feature imho. Maintaining a file reference count and deleting the file when the count hits 0 isn’t a small task, though.

1 Like

Perhaps it’s better to move those files in a folder “attachments_not_in_use” instead of more or less blindly delete them.

1 Like

A temp location could be handy in case you restore a note that you deleted by accident. or we can say that the used is responsible for restoring it from the “trash” folder or from backup.

ie
User deletes last note that references an attachment.
Obsidian deletes attachment
User restores note
attachment link is now broken.

Totally agree with the need of an “automatic removal” of attachments after a note was deleted. It is painful to do this manually and really a bummer when using the app with attachments. Please add something that takes care of this.

3 Likes

If you read the thread, there are plugins that do this.

1 Like

I use this plugins called nuke orphans btw

这个扩展非常棒
This extension is great!

Use case or problem

I would like that if I delete a note, I would be asked what to do with the documents linked in it, if they have no other references, whether to keep them or delete them.

Proposed solution

When I delete a note I would like that if there are linked media that are only in that note, I would be asked whether to keep them or delete them

Current workaround (optional)

All files remain