CLI tool to scan an Obsidian vault and report which Markdown files reference each image
Find a file
2026-04-10 10:40:09 +02:00
go.mod Add find-image-refs CLI tool with documentation 2026-04-08 08:00:09 +02:00
main.go Add find-image-refs CLI tool with documentation 2026-04-08 08:00:09 +02:00
README.md Add README 2026-04-10 10:40:09 +02:00

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  ![holiday](../Bilder/photo.jpg)

Bilder/map.png:
  notes/places.md:5  ![[map.png]]

Supported reference syntax

  • Obsidian wiki-links![[image.png]] and [[image.png|alias]]
  • Markdown image tags![alt text](path/to/image.png)
  • 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:

  1. Exact match against the vault-relative path
  2. Match by filename (basename) — useful for Obsidian's shortest-path links
  3. Match by filename without extension — so ![[photo]] resolves to photo.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 .