If you, like me, get annoyed by the index files Spotlight creates any time you create an external hard drive, you might want to try this hint. We're going to set up a launchd service which runs a script every time a hard drive is mounted. This script will touch the .metadata_never_index file (which prevents Spotlight from creating the index; see this hint) on the hard drive.
Let's start with the launchd service. Open Terminal and type the following, then press Return:
$ cd ~/Library/LaunchAgents/Create the file com.index.no_index.plist with your favorite editor (vi, nano, etc.), and insert the following XML code:
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.index.no_index</string> <key>Disabled</key> <false/> <key>Program</key> <string>/Users/*YOUR_NAME*/no_index</string> <key>StartOnMount</key> <true/> <key>RunAtLoad</key> <false/> <key>KeepAlive</key> <false/> <key>EnableTransactions</key> <true/> </dict> </plist>
Now we create the actual script. Go to you home folder by typing cd ~ , and create a file named no_index with your favorite text editor, with these contents:
#!/bin/bash for filename in /Volumes/* do if [[ $filename != "/Volumes/Macintosh HD" && $filename != "/Volumes/BOOTCAMP" ]] then file=$filename"/.metadata_never_index" touch "$file" fi done;
Mac OS X Hints
http://hints.macworld.com/article.php?story=2010050112180751