I'm fairly familiar with the mdfind
utility. I find it's very useful when I can't find a file or when I need to find a file with certain contents. The problem is that I need to exclude some files from mdfind
searches. I don't want to exclude the files from a single search (I know you can do this with mdfind -onlyin /path/to/directory/to/exclude
) but from all searches. The mdfind
man page says this:
The mdfind command consults the central metadata store and returns a list of files that match the given metadata query.
So I guess I have to exclude/delete the files from the "central metadata store" in order to exclude them from mdfind
searches. I'm wondering how I would do this.
Best Answer
The command
mdfind
uses the Spotlight backing store. If you go to the Spotlight pane of System Preferences and select the Privacy tab you can exclude files or folders from being indexed.It is also possible to modify the exclusions list at the Exclusions array of
/.Spotlight-V100/VolumeConfiguration.plist
but this does not appear to be officially supported. Current exclusions can be read using the command:New entries to the Exclusions array can be added using the command:
where /path/to/exclude is a path relative to filesystem root.
These entries appear in the System Preferences privacy list but do not appear to actually affect the search results even after running
sudo launchctl stop com.apple.metadata.mds && sudo launchctl start com.apple.metadata.mds
: