Using Automator to Show Hidden Files in Mac OSX
Here’s a quick tutorial in how to use Automator to create a Finder action that will show/hide hidden files in Mac OSX. I was inspired by the comments over on a blog post by Mike Sel.
- First, fire up Automator (the easiest thing to do is use the Spotlight Search magnifying glass in the top right corner of your Mac to find the App).
- Next, choose File > New… > Service
- Configure so Service receives no input in Finder
- Next it’s probably a good idea to put in an “Are you sure you want to do this?” prompt by using an Ask for Confirmation Action
- Finally, use a Run Shell Script Action and include the shell script below
- Save your action, for example as “Toggle Hidden Files” and from now on you’ll be able to choose it from Finder > Services > Toggle Hidden Files
Here’s the shell script, which I’ve posted this as a Gist on Github, so if you see any mistakes please recommend a fix over there.
Make sure to pick the /bin/sh shell.
is_shown=$(defaults read com.apple.finder AppleShowAllFiles) if [ $is_shown = "FALSE" ] then defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder else defaults write com.apple.finder AppleShowAllFiles FALSE killall Finder fi
And finally, here’s a screen grab to help put all of this gibberish into context.