Remove unused attachments

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)

4 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.

I use this plugins called nuke orphans btw