Manipulate items in privacy tab of spotlight using shell script

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: , , , , ,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: