Michael C Hogan

Agile Product Development & Innovation Strategy

By

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.

  1. 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).
  2. Next, choose File > New… > Service
  3. Configure so Service receives no input in Finder
  4. 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
  5. Finally, use a Run Shell Script Action and include the shell script below
  6. 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.

Use Automator to automate the showing and hiding of system files on Mac OSX

Use Automator to automate the showing and hiding of system files on Mac OSX