Mac OS X – Show / Hide Hidden Files in Finder

I always forget how to do this because I toggle this rather sporadically so I’m adding it to the public record.

To show hidden files in Finder pop open your terminal and type the text shown in the screen grab below.

To go back to hiding files we obviously just flip the AppleShowAllFiles flag to FALSE.

*Update*
As noted in the comments its nice to have the text available for easy copy and paste into your terminal.

Show:

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Hide:

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder

*Update 2*

You can use this script toggle between states:

# check if hidden files are visible and store result in a variable
isVisible=”$(defaults read com.apple.finder AppleShowAllFiles)”

# toggle visibility based on variables value
if [ “$isVisible” = FALSE ]
then
defaults write com.apple.finder AppleShowAllFiles TRUE
else
defaults write com.apple.finder AppleShowAllFiles FALSE
fi

# force changes by restarting Finder
killall Finder

You can also download an Automator application which will toggle hidden file visibility here:

http://www.brooksandrus.com/downloads/show_files.zip

178 thoughts on “Mac OS X – Show / Hide Hidden Files in Finder

  1. Brooks, thank you for your selfless deed of publishing such a wonderful gem of a tip.

    Please publish more..

    thanks

  2. Hi, thanks for the neat script.
    but toggle script doesn’t work for me…I copied and pasted:

    # check if hidden files are visible and store result in a variable
    isVisible=”$(defaults read com.apple.finder AppleShowAllFiles)”

    # toggle visibility based on variables value
    if [ “$isVisible” = FALSE ]
    then
    defaults write com.apple.finder AppleShowAllFiles TRUE
    else
    defaults write com.apple.finder AppleShowAllFiles FALSE
    fi

    # force changes by restarting Finder
    killall Finder

    Did I do it write?

  3. Never thought i’d say this but windows (at least the pre-metro ones) has way better file management than mac os… i mean why not have this in preferences???

    And why can’t i merge two folders of the same name…

    sigh

  4. One additional tip: Make an alias of the directory (in my case the Library) Now, I can access the Library by just clicking on the alias and don’t need to perform the Terminal gymnastics just to access an old preferences file on my former back up drive.

  5. Thank you Gray Dog, now I don’t have to worry about my kids getting their hands into files they shouldn’t and I don’t have to toggle back and forth.

  6. Awesome, was struggling with hidden files being visible all over the computer. So simple fix, thanks a lot.

  7. The cut-and-paste code doesn’t work because it uses “smart” (curvy) double-quotes instead of straight quotes. Fix that and it works fine.

  8. Another way to do this is to add a couple of aliases to your .bashrc file. Then everything can be done right from the command line, no Automator app needed. You will need admin access to edit .bashrc.

    In Terminal, open your .bashrc file with nano(or your editor of choice)

    sudo nano ~/.bashrc

    Then paste in these 2 lines:

    alias inv='defaults write com.apple.finder AppleShowAllFiles FALSE
    killall Finder'
    alias vis='defaults write com.apple.finder AppleShowAllFiles TRUE
    killall Finder'

    Then save/exit the .bashrc file.

    These aliases won’t be available until we either restart or reload the file. You can reload with this command:

    source ~/.bashrc

    Then all you have to do is type inv or vis in terminal to do the deed.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>