Read a File's Spotlight Metadata with mdls
Dump every indexed attribute of any file: EXIF, dimensions, duration, authors, content types.
Run `mdls <file>` to list all metadata attributes, or `mdls -name kMDItemPixelWidth <file>` for a single value.
01Command
Command
$ mdls -name kMDItemContentCreationDate IMG_0001.jpg02What it does
mdls reads exactly what Spotlight indexes, so it shows the attributes mdfind queries against — camera model, ISO, audio codec, PDF page count, and dozens more depending on file type. It's the quickest way to verify why a file does or doesn't match a Spotlight search, or to script metadata-driven sorting. If a file shows no metadata, it isn't indexed yet; run `mdimport <file>`.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- macOS mdls — display Spotlight metadata attributesEvidence: Documents mdls attribute listing and -name filtering per file.
Last verified: 2026-09-17 · Category: Files & Folders