Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi there,
I know you can exclude directories from the Spotlight index by going into System Preferences > Spotlight > Privacy, but is there any command line interface to this, please?
I have a handful of directories I'd like to add, maybe based on using a `find` or a `grep`, and it would just be really useful to be able to do something like `some_mdcommand --exclude /path/to/dir`.
A google search only returned that you may be able to edit a .plist file to add exclusionary directories, and that's really not what I want.
Imported from the Apple Support Forums via the Wayback Machine 🔗
The file to modify is /.Spotlight-V100/Store-V1/Exclusions.plist which only exists if there is atleast one directory excluded.
I would think I could modify this with *sudo defaults write /.Spotlight-V100/Store-V1/Exclusions -array-add /path/goes/here* but it does not work and mangles the file. Perhaps I am using array incorrectly and someone else will chime in. Even writing the line in with nano does not show the change in the pref pane of spotlight.
You might be better off doing this one in the GUI.
0
Jun T.·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Note that the path/to/exclude is not an absolute path but a relative path to / (or top of the volume if it is not mounted at /).
But I don't know whether manually editing this plist file is safe or not; as ridogi writes, the results of maual editing does not show up in the Splotlight Preference Pane (unless you reboot).