brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mdimport asks Spotlight to index one folder again, and shows what it reads

Spotlight
~/tips/tip-spotlight-mdimport-reindex-folder

mdimport -i ~/Documents/Invoices

Re-index a single folder or test what Spotlight extracts from one file.

When Spotlight can’t find one specific file, rebuilding the whole index is a big hammer. mdimport works on just the files or folders you name.

Ask Spotlight to import a folder again, recursively:

mdimport -i ~/Documents/Invoices

The man page says -i requests Spotlight to import the file or recursively import the directory, using the normal mechanisms, with the attributes stored in the index. It’s also what happens if you give no option at all.

The test mode is the part I find most useful for troubleshooting. With -t the file is imported only for a look, nothing is stored, and -d1 prints a summary:

mdimport -t -d1 ~/Documents/Invoices/2026-03.pdf

The output names the importer plug-in that handled the file and how many attributes it returned. If no suitable importer is listed, or very few attributes come back, you know why searching for words inside that file fails. -d2 prints the attributes themselves, except the text content. mdimport -L lists every installed importer.

Know its place. The man page describes mdimport as a tool to test Spotlight plug-ins and re-index files after a new plug-in is installed. If nothing at all shows up in Spotlight, check with mdutil -s whether indexing is on for that volume first; and a folder you put in Search Privacy stays out, however often you import it.

Further reading: mdimport.1 man page, mdutil.1 man page

More Spotlight tips Command-2 Files double-click backup-2025.zip unpacks it next to the zip Tab show the Quick Actions for that result "trip to Paris" Results from Apps / System / Clipboard: switch categories off All Spotlight tips (14) All topics

Link