Skip to content

Quickly toggle visibility of invisible files in Finder

Update: If you're running macOS Sierra, ignore the rest of this tip because it's irrelevant! I had no idea Shift-Command-Period would show/hide hidden files directly in Finder in macOS Sierra. Thanks to NaOH for the great tip via the comments!

Basically, if you want to show invisible files in Finder in Sierra, pressing ⇧⌘-Period will toggle them between hidden and visible. Nice! If you're on an earlier version of macOS/OS X, however, you may find the macro version useful for easily showing and hiding hidden files in Finder.

This remains here as a reminder of The Hard Way of doing this…

A long-standing—since March of 2001—Mac OS X Hints tip reveals how to display hidden files and folders in Finder. Despite its age, this tip still works in macOS Sierra. Now, normally I don't want to see all the invisible Unix files in Finder, but there are times (like when I'm working on a web site that might have an .htaccess file) that I want to see them. All it takes to see them is one command and a Finder restart in Terminal:

$ defaults write com.apple.Finder AppleShowAllFiles YES
$ killall Finder

To hide them again, you can either set the pref to NO, or just delete it (defaults delete com.apple.finder AppleShowAllFiles) and then restart Finder again.

I wanted to make this toggling simpler, so I wrote a Keyboard Maestro macro to check the current state and reverse it.

Here's how the macro looks—as always, you can download it for your own use/modification.

The key to this script is actually in the hidden second step (sorry!) in the above image: The "Excecute Shell Script" command is this one:

defaults read com.apple.finder AppleShowAllFiles

That command reads the current value of the hidden pref—it'll either be YES or it won't exist—and saves it to a variable. Once saved in the variable, an "If" loop checks the saved value and either sets or deletes the "show invisible" flag. The AppleScript at the end relaunches the Finder in a slightly nicer way than does just killing it in Terminal.

This works quite well for me; I can see the hidden files when I want them, and hide them again, all with the same command. (Right now, I have it running in Finder only, and via the Keyboard Maestro menu bar icon so I don't need to remember a keyboard shortcut.)

9 thoughts on “Quickly toggle visibility of invisible files in Finder”

  1. I'm not running 10.12, but I believe in Sierra the Command-Shift-. [period] shortcut that long worked in Open/Save dialogs now works in the Finder for togging hidden file visibility.

  2. Sorry, (CMD-Shift-period) does not work anymore in Sierra... Easy way to toggle is to download Houdini... (free)

    1. It does work fine in Sierra - using it in 10.12.4 right now, in fact.

      -rob.

  3. prehensileblog

    If you expect to find the .DS_Store file inside any folder opened in icon view in Finder, you may be surprised, as I was. I can't find them now. When did they go away? Anyway, to check the shortcut, try making sure you're viewing main boot volume folder or Home folder in Finder when you trigger it.

    1. That makes more sense. In El Cap, it should work in open/find dialogs; Sierra expanded it to Finder.

      -rob.

  4. For me it only works if no file/folder is selected. If there's a selection, it tries to open OmniOutliner Clipping Service. I'll have to find that keyboard shortcut and kill it.

Comments are closed.