First get the permissions.
sudo chown -R $USER:$GROUP /.Spotlight-V100/
sudo chmod -R 777 /.Spotlight-V100/
Write items
sudo defaults write /.Spotlight-V100/Store-V1/Exclusions Exclusions -array-add ‘/Users/xxxx/Downloads’ ‘/Users/xxxx/Documents/’ ‘/System’
Read items
sudo defaults read /.Spotlight-V100/Store-V1/Exclusions
Delete items
sudo defaults delete /.Spotlight-V100/Store-V1/Exclusions Exclusions
Revert back the permissions.
sudo chown -R root:admin /.Spotlight-V100/
sudo chmod -R 700 /.Spotlight-V100/
Delete specific items
#!/bin/sh
appspre=`sudo defaults read /.Spotlight-V100/Store-V1/Exclusions Exclusions`
appspost=`echo $appspre | sed ’s/\/xxxx//g’ | sed ’s/["(),]["(),]*//g’`
sudo chown -R $USER:$GROUP /.Spotlight-V100/
sudo chmod -R 777 /.Spotlight-V100/
defaults delete /.Spotlight-V100/Store-V1/Exclusions Exclusions
defaults write /.Spotlight-V100/Store-V1/Exclusions Exclusions -array-add $appspost
sudo chown -R root:admin /.Spotlight-V100/
sudo chmod -R 700 /.Spotlight-V100/
Blogged with Flock
Tags: spotlight, privacy tab, shell script, shell, script, sed
