CLI tool to scan an Obsidian vault and report which Markdown files reference each image
- Go 100%
| go.mod | ||
| main.go | ||
| README.md | ||
obsidian-find_image_refs
A command-line tool that scans an Obsidian vault and reports which Markdown files reference each image stored in the vault's images directory.
Usage
find-image-refs [-vault <path>] [-dir <images-dir>]
Flags
| Flag | Default | Description |
|---|---|---|
-vault |
. (current directory) |
Path to the Obsidian vault root |
-dir |
Bilder |
Images directory, relative to the vault root |
Example
find-image-refs -vault ~/Documents/MyVault -dir Attachments
Output
For every image referenced by at least one Markdown file, the tool prints the vault-relative image path followed by each reference location:
Bilder/photo.jpg:
notes/trip.md:12 ![[photo.jpg]]
notes/trip.md:34 
Bilder/map.png:
notes/places.md:5 ![[map.png]]
Supported reference syntax
- Obsidian wiki-links —
![[image.png]]and[[image.png|alias]] - Markdown image tags —
 - Bare Markdown links —
[text](path/to/image.png)
URL-encoded paths (e.g. My%20Photo.jpg) are decoded before matching. Remote URLs (http://, https://) are ignored.
Image resolution
References are resolved in the following order:
- Exact match against the vault-relative path
- Match by filename (basename) — useful for Obsidian's shortest-path links
- Match by filename without extension — so
![[photo]]resolves tophoto.jpg
If the same filename exists in multiple sub-directories, all matches are reported.
Build
Requires Go 1.21 or later.
go build -o find-image-refs .