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.
Asked
Active
Viewed 746 times
1 Answers
2
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'.

joshbillions
- 1,048
- 8
- 19
-
As of macOS Mojave the 2nd option (adding a '.metadata_never_index' file) doesn't work anymore. I.e. macOS ignores it. – 0xZ3RR0 Jun 26 '21 at 13:14
-
1`touch .metadata_never_index` is a completely valid way to accomplish the task "via command line" !! – Greg Fenton Jun 26 '22 at 15:45