This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/bash | |
launchctl stop com.apple.metadata.mds && launchctl start com.apple.metadata.mds | |
vers=$( sw_vers | grep BuildVersion | awk '{print substr($2,0,2)}' ) | |
sdir="/.Spotlight-V100" | |
if [[ "${vers}" > "18" ]]; then | |
sdir="/System/Volumes/Data${sdir}" | |
fi | |
cd "${sdir}" | |
# First let's check if the directory we're adding already exists | |
search_string=$1 | |
let index="`plutil -extract Exclusions xml1 -o - VolumeConfiguration.plist | grep string | grep -wn "${search_string}" | cut -d ':' -f 1` - 1" | |
if [ $index -lt 0 ]; then | |
echo Not in array, let\'s add it in. | |
plutil -insert Exclusions.0 -string ${search_string} "${sdir}/VolumeConfiguration.plist" | |
else | |
echo Already in array, not doing anything. | |
fi | |
# Now we restart mds to apply the changes | |
launchctl stop com.apple.metadata.mds && launchctl start com.apple.metadata.mds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment