Search with Spotlight from Terminal (mdfind) — via SS64
mdfind runs Spotlight searches from the command line, so it's instant even across your whole drive. It can search by name, by content, or by metadata like 'images edited yesterday' or 'files tagged Green'.
Takes effect right away
The easy way
mdfind -name report.pdffinds files by name;mdfind budgetsearches contents and metadata too.-onlyin ~/Documentslimits the search to one folder;-countjust counts matches.- Metadata searches:
mdfind "kind:image date:yesterday",mdfind "kMDItemUserTags = Green", ormdfind kMDItemAppStoreHasReceipt=1to list App Store apps.
Command
Run in Terminal (Applications › Utilities).
mdfind -name invoice -onlyin ~/DocumentsIt only finds what Spotlight has indexed, so folders excluded in Spotlight settings won't show up.
Sources
- mdfind — by SS64
- Source reviewed
- 2026-11-02
- Link checked
- 2026-11-02
- Tested hands-on
- Not by Oddbyte.Me
Oddbyte.Me hasn't tried this on every macOS version, so keep the undo handy.