There are certain things I find I do now and again which would be nice to automate. One of them is revealing hidden files, on a mac that means the file name begins with a period, like a .htaccess file. Typically I would go into terminal, write a little shell command and then I'd have a messy desktop and file browsing until I got around to hiding hidden files again. So I wrote the below shell script which will do this switch for me. I've even set it up as a trigger in Quicksilver so I can toggle it on and off with a keyboard shortcut. Pretty simple!
set hiddenState to (do shell script "/usr/bin/defaults read com.apple.Finder AppleShowAllFiles")
tell application "Finder" to quit
if (hiddenState is "ON") then
do shell script "defaults write com.apple.finder AppleShowAllFiles OFF"
else if (hiddenState is "OFF") then
do shell script "defaults write com.apple.finder AppleShowAllFiles ON"
on error myError
display dialog "problem:" & myError
tell application "System Events"
if (name of every process) does not contain "Finder" then
tell application "Finder" to launch