Delete unused media

Sometimes I add an image then decide to change/remove it. However, it doesn’t get deleted from the vault. All the unused images could pile up and take up space in the cloud. There could be an easy plugin to delete them.

Edit: or any media in general

32 Likes

Perhaps a better title might be ‘Delete Unused Images’, rather than ‘unlinked’.

An even better idea might be to ‘Delete Unused Media’ - which might refer to files beyond just images (like sound/video files, PDFs, etc.).

6 Likes

Excellent point, I’ve made the topic more general

1 Like

I use Greenshot to take screenshots of interesting art effects & techniques pretty regularly, and I’ve already run into this problem. If I take a couple screenshots and paste them into Obsidian (which I’m super happy with) but I later delete one or want to replace it with a better example, I end up with a pile of extra images that I can’t easily sort out manually.

3 Likes

I just do it through file explorers etc.
I prefer having maximum power available.

My problem with this solution is that I have no idea which files are unused by looking at them in a file browser. So I might delete the wrong thing, or have to manually sort through all my attachments to figure out what to delete.

2 Likes

I find careful naming avoids most problems, though that does require remembering what was deleted from the notes.

Separately I use a sophisticated image database and am very used to managing versions, sizes, conversions etc. I’m systematic with images because they clog up so much bandwidth and space. I don’t see a need to use it with Obsidian notes, but it would be a simple matter if I had it select the Obsidian folders to examine.

By “sophisticated image database” do you use specific software to achieve that or do you just mean that you have everything well organized?
If you do use some kind of software would you mind sharing?

I’m asking because this thread’s problem is currently my problem but with a tool outside of Obsidian that would do the trick. That and because managing images outside Obsidian is not something I do particularly well right now as well.

1 Like

I’ve used photools’ IMatch for some time.
There are many alternative digital asset managers, some free, and I’ve tried some of them. This one has been going a long time with a very active user community. Single developer, Mario. Not cheap, but wasn’t the most expensive either last time I looked.

Massive overkill for most people, and it’s best to find a program with the level of function you actually need else you’ll be overwhelmed by complications you don’t understand and will never need.

1 Like

Thanks for sharing.
I’ll look into it and I’ll also take your advice to look for something that might fit me better.

You’re welcome.

A few years ago I’d have been able to make useful suggestions for all types of use, but I’ve stuck in IMatch too long to be up-to-date with what’s gone on outside.

The IMatch community is ultra helpful if your use case matches any of theirs. There’s a lot of people there who really know what they’re doing. I visited often even when I didn’t use the program. They tend to be aware of all the alternatives on the market.

1 Like

Still no proper obsidian?
Anyone has any idea how to get rid of unused photos and media?

1 Like

I think this would be better as a core feature than a plugin. Feature requested here.

1 Like

I think my plugin find unlinked files fixes exact that problem. It finds files (also attachments) which are nowhere linked (orphans) and lists them in an output file. With an extra command you can delete all files listed there with a certain extension. You can choose which extensions to delete in the settings. In this case it could be .jpg

6 Likes

Thanks for creating the plugin. It’s very helpful. How do you delete all the unlinked files after it open a list of unlinked files in a new pane? I read the readme.md but it doesn’t show you what command to use. Thanks.

Just search in the command palette for delete. It’s called Delete unlinked files with certain extension. See README

1 Like

That’s what I did before I write the message to you. When I select “Delete unlinked files with certain extension. See README” Nothing happen. The Command window disappear and it didn’t delete any unlinked files. Do you think this is a bug with Obsidian v0.13.19 beta. That’s the latest version I’m using.

How do you specify which file type you want to delete? I read the readme.md file but it doesn’t show you how to do it.

@magi44ken

Goes through every link in the output file. If the extension of the link is in the list (can be set in settings), it moves the file to system trash.

There’s a field in the settings pane.

grafik

1 Like

I didn’t know you have to specify the file extension in the plugin setting in order to delete it. I tried three times but it freeze Obsidian. Maybe it have too much files to delete and need to sort before delete? I waited 10 minutes the max.

I have a few suggestions for improvement.

  1. Add: Delete All Files
  2. Add: Delete Image Files
  3. Add: Delete Video Files
  4. Finding Unresolved Files or Links: Show the total number find when viewing the result.
  5. When deleting the actual files, show a progress window of how many files to be deleted and how files is deleted and left during deleting progress.

@Vinadon: thanks a lot for the plugin. Pretty confusing setup, though :slight_smile:

My target was to identify unlinked attachments. Attachments are placed in _resources/ directory.

So, I eventually ended up with these changes to the default plugin options:

  • Ignore or include files in the given directories: Off
  • Directories: _resources
  • Ignore or include files with the given filetypes: On
  • Filetypes to delete per command. See README.: *

Then I ran commands:

  • Find unlinked files and unresolved links: Find unlinked files, which created and opened the unlinked files output.md in root directory.
  • Find unliked files and unresolved links: Delete unlinked files with certain extensions. See README, which deleted the previously identified unlinked files.

As people may be using your plugin for different purposes, it might be helpful to have some kind of “Profiles”, which would remember all the options. Like “Find and delete unused attachments”, “Find and delete unlinked notes”, …