Search code examples
macoscommand-linespotlight

Exclude folder from Spotlight indexing - via command line


Is there a command-line way to exclude folders from spotlight indexing? To do it via UI, you can use System Preferences >> Spotlight >> Privacy. But I'd like to be able to add various folders/directories to that Privacy list via command line.


Solution

  • I'm sure this isn't exactly what you meant by 'via command line', but you can add the extension '.noIndex' to a folder to have it ignored by Spotlight, or create an empty file in the folder named '.metadata_never_index'.