Remove unused attachments

This topic is particularly useful for those situations in which:

  • one comes to obsidian from another platform
  • one makes a mistake when clearing up attachments or attaching them

Operationally I would imagine a process that:
a. Allow the use to select a folder to be processed
b. The process would ennumerate each file in the selected folder and remove those that are referened int he vault.
c. Show the user the list of orphaned files and allow them to check those they want to remove.

1 Like

+1

This needs to be a core feature.

5 Likes

+1 would really appreciate this being implemented

2 Likes

I tested some of the mentioned plugins - some of them only take into account wikilinks ([[]]), and do not take into account markdown links ([]()), others do not take into account links located in .canvas files, not .md.

This is in addition to some strange settings, where disabling the work of exceptions, I have the plugin stops performing its function in principle.

I would like a native implementation of this feature, - more stable and reliable, covering all possible scenarios of using media files, and which can be trusted. Perhaps implemented in such a way that I can actually make sure that all the files I’m about to delete are not being used by me anywhere. I have no idea how this feature could be implemented in such a way that I can be sure that all the files I plan to delete are really not used anywhere, because even if all the files are listed in a table format with ā€œfileā€ and ā€œbacklinksā€ columns, and there are no links in the ā€œbacklinksā€ column, how can I be sure that the native implementation of this feature has really accounted for all possible usage scenarios? Only by verifying the reliability of this feature through my own experience, I suppose, and ā€œblindly trustingā€. Only, unfortunately, through experience I can also be convinced otherwise, and lose the files I need (which has happened in the past with one of the plugins mentioned in this thread. Fortunately, there was a relatively fresh backup).

4 Likes

Raising again because I have not found a satisfactory solution.

I did it with a python script, but that was not very efficient.

3 Likes

Any progress on this from the developers?
From myself I will add: it is important to create a delete delay (since I can move the attachment to another place via cut). Delay for example from 5 minutes to several days. I understand that technically this is not the most trivial task as optimization is required. But I think deleting attachments may be part of indexing - in any case not all files were edited after the last indexing, etc.

External solutions are not satisfactory, e.g. a post written 18 days ago on Reddit:

Update 2025 - just tried using this and it deleted images attached to some of my notes. I uninstalled this plugin.

/r/ObsidianMD/comments/10nntrg/cleaning_unused_attachments/

One day the orphaned files problem will be solved. I truly believe that!

For those who say that there are plugins … which plugins are reliable? Which ones would you stake your reputation on?

As a person who use images in his notes a lot, I need this feature so much.

1 Like

Keep good backups (not a sync tool). And also take a version snapshot with a tool like git. Or make a duplicate test vault. Then you don’t need someone’s reputation; you can just test and see.

I wouldn’t use any plugin that deletes stuff without backing up first. And with git, you can review what changed, or fix a mistake (user or plugin).

1 Like

I would like to add to this Feature Request a request to identify similar images and replace them with a single selected image, followed by the deletion of unnecessary images.

This will also help optimize the media files used – sometimes the same image is used several times in different notes, and due to the lack of convenient media file management in Obsidian, this image is attached as a new one, resulting in the same image being used several times in the context of a single vault.

Currently, Duplicate Cleaner is a solution, but it is not connected with Obsidian and can only identify and suggest deleting duplicate images, but not automatically replace links in files.

I understand that Obsidian is not software for detecting and subsequently cleaning duplicate files, but this is what is missing.
Perhaps it would be more appropriate to implement such functionality in the form of a ā€œbridgeā€ between software for detecting and cleaning duplicate files and Obsidian itself. Perhaps by the community, rather than the core developers.

Obsidian October encourages users to keep their vault clean, but there are no tools to do so.
This applies to both keeping media files and properties clean – Show existing values in Properties view .

Bumping, since there’s still no solution for this.

is this solve the problem?

Use case or problem

I love the new feature in v1.12 that prompts you to delete unused attachments when you are deleting a note. This solves a lot of problems with attachment management. The one problem it currently doesn’t solve (as far as I can tell) is the following: if you remove the reference / link to an attachment from a note (not delete a note), the orphan attachment still remains in your vault.

Proposed solution

Provide a prompt to delete an unused attachment when you delete a reference to it from a note, similar to the new prompt shown when deleting a note.

Current workaround

They exist but are either tedious, e.g. having a base query to find orphan files and deleting them manually, or require a community plugin (for a feature that should be built into Obsidian, and I suspect the developers agree based on the inclusion of the new feature in v1.12).

Related feature requests

There are several feature requests related to orphan attachment management, but none yet that place this feature request in light of the new developments in v1.12.

1 Like