by Atlas Creative
Find attachments that no note or canvas uses, see how much space they take, and move the ones you pick to trash or an archive folder. Also merges duplicate files, with undo.
Attachment Sweeper
Vaults collect images, PDFs and recordings that no note uses any more: a screenshot you replaced, a PDF from a note you deleted, a pasted image you never kept. They also collect the same image saved twice under different names. This plugin finds both, shows you every file and its size, and only changes what you pick, after you confirm.
Features
- Counts every kind of link: wikilinks and embeds (
[[file.pdf]],![[image.png|300]]), markdown links and images (,[doc](<my file.pdf>), relative paths like../img/a.png), HTML tags (<img src="...">,<embed>,<a href="...">), links in frontmatter and plain paths there such as acoverorbannerproperty, and canvas file cards, group backgrounds and links in text cards. Note text is read directly too, so links inside code blocks and in Excalidraw drawings' embedded files count. - Covers links built by plugins: Dataview, Templater and similar plugins can build a link from a file name when the note renders. With Keep files named in a note on (the default), any file whose name appears anywhere in a note counts as used. The review list and the report say how many files were kept this way.
- Review list: every unused attachment with its path and size, largest first, and the total. Nothing is selected until you select it.
- Trash or archive: after you confirm, picked files either go to trash through Obsidian, so your Deleted files option in Settings → Files and links decides where they go, or into an archive folder in your vault, keeping their folder structure, so you can move them back. Links are checked again just before anything moves, and a file that got a link since the scan is kept.
- Duplicate finder: finds files with identical content, whatever their names, and shows each set with how many notes link to each copy. Pick the copy to keep, and the plugin points every link at it, in notes, frontmatter, HTML tags and canvases, then moves the other copies to the archive folder. Undo last duplicate merge puts the links and the files back. A copy that something still refers to after the merge, such as a plugin that builds its link from the name, stays where it is.
- Dry-run report: writes a note listing every unused attachment and its size without moving anything. Paths are written as code, not links, so the report never makes a file count as used.
- Excluded folders: attachments in these folders are never listed, moved or merged.
Notes (.md), canvases (.canvas), bases (.base) and Excalidraw drawings are never listed as attachments. The archive folder is never scanned.
Usage
- Run Attachment Sweeper: Find unused attachments from the command palette, or click the paperclip icon in the ribbon.
- Select the files you want to remove, or press Select all.
- Press Move to trash (or Move to archive) and confirm.
To see the list without changing anything, run Attachment Sweeper: Write unused attachments report (dry run).
To merge duplicates, run Attachment Sweeper: Find duplicate attachments, turn on the sets you want to merge, pick the copy to keep, then press Merge and confirm. Run Attachment Sweeper: Undo last duplicate merge to put everything back. Undo leaves alone any note you edited after the merge.
Settings
- Excluded folders: comma-separated. Attachments in these folders are never listed or moved. Links from notes inside them still count.
- Keep files named in a note: count a file as used when its name appears anywhere in a note. Safer, but it may keep a few unused files.
- Unused files go to: trash, or the archive folder.
- Archive folder: where archived files and merged duplicates go. Default
Archive/Unused attachments. - Report note: where the dry-run report is written. The note is replaced each time you run the report.
Privacy
Everything runs locally. The plugin makes no network requests.
Installation
Manual
Copy main.js, manifest.json and styles.css into <your vault>/.obsidian/plugins/attachment-sweeper/, then enable the plugin in Settings → Community plugins.
Development
npm install
npm test # unit tests for link detection, the scan, the report, trash and archive, and duplicate merges with undo
npm run lint # ESLint with eslint-plugin-obsidianmd
npm run build # type-check and build main.js
Releases
Publishing a GitHub release tagged with the version in manifest.json (for example 1.0.0) runs the Release workflow. It lints, tests and builds the plugin, attests build provenance for main.js, and attaches main.js, manifest.json and styles.css to the release.
Support
If this plugin saves you time, you can sponsor me on GitHub.
License
0BSD
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.