Remove unintegrated image-files from attachments-folder at startup/regularly

Things I have tried

  • general look through settings, help vault, and brief (and unsuccessful) search online

What I’m trying to do

Hello, I am mostly using Obsidian as an actually quite fast way of writing lecture notes during lectures. As such, a lot of screen-grabbing at pasting also ensues. However, not every image I grab I will ultimately also end up incorporating, often because an image is updated later on and I generally only keep the final version.
However, this ends up bloating the corresponding subject’s asset/attachments-folder. As such, I now have almost twice as many images as are actually embedded in the file.

Therefore, is there a way to clean up the corresponding asset-folder of any md-file opened in a session when shutting down obsidian? That would probably be the best bet, because that way the program should be able to fetch all embedded files present when the user quits. Then it could compare that list against the set on disc and delete any non-matching entries.

At least that would be my initial idea of how to do this. I can probably pseudo-fix it with a few hours and AutoHotkey, but I’d assume this to be a general problem that should have an internalised solution, instead of everyone cooking up their own fix for it.

There is a plugin called Clear unused Images which allows you to perform the cleanup manually.

obsidian://show-plugin?id=oz-clear-unused-images

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.