After reinstalling some development software the other day I needed to access some XML files that were in a hidden directory. Typically I would filter all my access to hidden files through the appropriate Terminal commands but I decided to look for a more elegant solution. Immediately, I found the following Terminal command that directs Apple Finder to show all hidden files:

defaults write ON

That's at least a start, but I don't want to fire up Terminal to run two simple commands, one to turn on hidden file viewing and one to turn it off - plus, restarting Finder altogether. After digging around a bit I found an AppleScript that automates the process. I made a few adjustments to suit my needs and I was in business. Seeing how useful my MusicStoreAutoPlay script was I decided to offer this one up as well.

Here are some installation instructions:

  1. Download the zip, and extract the AppleScript file to the /Users/your-user-name/Library/Scripts folder. If this folder doesn't exist, create it.
  2. The Finder does not have a "script" menu like iTunes does so I recommend turning on the system-wide "Script Menu." Navigate to /Applications/AppleScript/ and double-click the "Install Script Menu" Application. This will create a new "script" menu that shows in the menu bar (upper right near the clock). You can use this script menu drop-down to access the ToggleHiddenFiles AppleScript.
  3. Here's a link with more info on the system-wide Script Menu.
If you have any questions or something doesn't go right, just let me know. Enjoy.

Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on March 10, 2006 at 10:04 AM. It was filed in the following categories: Programming, Mac. It has been viewed 11450 times and has 6 comments.

6 Responses to AppleScript to View Hidden Files on Mac

  1. Ernesto

    Thanks, this is just what i needed as an ex-ubuntu user :)

  2. mike

    FYI, this didn't work on my macbook-tiger, so I opened it in script editor and changed instances of "ON" to "TRUE" and instances of "OFF" to "FALSE". Works fine now. Thanks.

  3. That's interesting Mike. I've heard a few users mention my script not working on Leopard but you are the first to have any problems with Tiger. I don't have a Tiger machine to do any more testing otherwise I'd look into this. Thanks for for commenting.

  4. Hi,
    I just tried this as well and it gives me an error. I'm using leopard. The error it gives is this:

    Finder got an error: 2009-07-03 13:15:32.396
    the domain/default pair of (,AppleShowAllFiles0 does not exist

  5. Folks having problems with my script - now four years old - might want to check out this Macworld article posted today. It talks about current solutions to showing hidden files as well as a few old solutions.

  6. jim

    your tip works like a wonder
    thanks a lot mike!