Quick Tip: Show/Hide Hidden Files
A few months ago I started to mess around with a .htaccess file in connection with one of my websites. When I transferred the file from my web server to my desktop via FTP, the file never showed up. I tried again and again, but that dang file would never show up.
After a little searching, I realized that .htaccess is one of the files that OS X hides by default so that you don’t accidentally delete and/or alter it. However, there are times that you need access to those files. Unfortunately Apple hasn’t made it as simple as toggling a menu item in Finder. Instead, you’re going to to have to write out a line or two of code. But if you follow the following few steps, you’ll be able to use Automator to create a plugin that you can use to toggle the view of hidden files from within Finder.
Step 1: Automator Actions
After opening Automator, select Automator from within the Applications Library on the left-hand side. You’ll now see a number of different built-in actions that are available to the Automator application.

Select Run Shell Script from the list of available actions, and drag it into your workflow.
Type (or paste in) the following code into the Run Shell Script text box:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Step 2: Save As Plugin
Now that your Automator workflow is finished (yes, that’s it), choose File > Save As Plugin… and choose Finder as the Application. Save your plugin-in as ShowHiddenFiles or something else descriptive.

Now, from the Finder or desktop, simply right-click (or cmd-click) and the contextual menu will appear. Choose Automator > ShowHiddenFiles and the Finder will restart showing all your hidden files.

Step 3: Repeat
Seeing all those hidden files can start to be annoying and can lead to some unfortunate accidents if you happen to delete something you shouldn’t. So as soon as you’re done with the hidden files, simply edit the above workflow by substituting “FALSE” for “TRUE” and save the new plug-in as HideHiddenFile.
Now showing and hiding system files is as easy as a click away.

Trackbacks/Pingbacks (Trackback URL)
Comments RSSComments

#1 Adam says:You sure this works?
I keep getting “Workflow Failed”, so have I missed anything?

#2 vanni says:I use an AppleScript called “Show Hide Invisible Files 1.5″ …dead simple.
J. T. AppleScripts - http://216.127.146.15/~j_gar@trysb.net/

#3 Grkness says:It works perfectly fine. Vanni: you could use third party software however it takes the fun out of learning the intricacies of your Mac.

#4 vanni says:@grness. you are right. i just finished your tutorial and it was indeed fun and informative. thanks!

#5 Dan Diemer says:or, install MainMenu and have this one click away, along with the handy Repair Disk Permissions

#6 Si says:What would be great is if you could apply it to just a single folder, or hierarchy of folders. Specifically, I have Apache installed so I’d like to see all the hidden files in the htdocs folder, but nowhere else. That would be cool.

#7 James says:I get workflow failed on both as well…

#8 Jason Guthrie says:Adam and James…
Always check the log when troubleshooting a “Workflow Execution Failed” message. To view the log, select ‘Show Log’ in the ‘View’ menu. If the fix isn’t obvious, post another comment with the log results… maybe we can help.

#9 matthijs says:I get a workflow failed as well. “An error 2007-05-01 09:20:18.830 defaults[251] Unexpected argument Finder; leaving defaults unchanged. 91) occured in Run Shell”

#10 matthijs says:Strange, because if I run the commands from the Terminal, they work fine. I’m on OS X 10.4.9 by the way.

#11 heracek says:Replacing newline with ‘;’ works:
defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder

#12 Uli Kusterer says:You shouldn’t use killal. Use osascript to ‘tell application “Finder” to quit’. killall forces the Finder to quit and it’ll forget all its window positions, while the AppleScript solution makes Finder exit gracefully.

#13 Ankur says:Quicksilver has a “Run command in Shell” command, so you can also set up a trigger for that extra speed boost.

#14 dandam says:If you have workflow problems, maybe because you copied the code from this page. The code contains a line break. Remove it in the Automator (add it again, if you like) and things work fine.
Leastways, that solved it for me.

#15 Mattebo says:“You shouldn’t use killal. Use osascript to ‘tell application “Finder” to quit’. killall forces the Finder to quit and it’ll forget all its window positions, while the AppleScript solution makes Finder exit gracefully.”
I tried this but I forgot to add another ‘Run Applescript’ to the workflow stating ‘tell application “Finder” to run.’ I eventually figured it out. I didn’t like having to relaunch the Finder from the dock.

#16 Daryl says:This is an awesome tip. Thanks!

#17 Mr. Buyer says:Dude
I have had my iBook for two years and haven’t really used terminal or Automator. That easily worked for me. Now, can we delete the plugins?

#18 vytas says:i love apple and people who share skills! thanks for tip. very usefull

#19 tomg says:this tip is exactly the solution that i was looking for. i’ve found a lot of terminal command answers to showing hidden files, which is great, but adding show and hidefiles to a menu is perfect. thanks

#20 brb says:“defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder” … that stops the newline also.

#21 mellow says:I used the osascript to ensure that the folders I currently have open will reappear correctly.
defaults write com.apple.finder AppleShowAllFiles FALSEosascript -e 'tell application "Finder" to quit';
osascript -e 'tell application "Finder" to activate';

#22 angry says:i am VERY angry at this
i can not make the hidden files disappear again
can someone please help me?

#23 Promitheas13 says:Don’t be angry and simply do the following:
1) Open your terminal
2) Enter the following command and then enter
defaults write com.apple.finder AppleShowAllFiles NO
3) That will hide your files… now enter the last command to reset your finder and press enter again:
killall Finder
4) You are ready now
p.s. I don’t think the above from “mellow” works on terminal so, it’s something i don’t suggest. You can try if you want though!
osascript -e ‘tell application “Finder” to quit’;
osascript -e ‘tell application “Finder” to activate’;

#24 Jimbows XP says:Works like a charm. Thank you.
I was tired of looking up the command everytime I needed to make visible hidden files.

#25 Melanie says:I just did this and it worked great. Thanks! But I thought when I did this, it would change it for my computer across the board, but it didn’t. What I mean is, even when I can see hidden files and folders in the Finder, when I am in Safari and need to browse for something via a “Choose File” link on a webpage, none of the hidden stuff shows up. So apparently this doesn’t work in Safari just because it’s set up in Finder. How do I see hidden files and folders when browsing for them in Safari? I don’t suppose it’s as simple as changing the .finder part of the code to .safari … ??? I would try it, but I don’t want to mess anything up. This is the webpage I’m trying to do it at: http://www.bluechippy.co.uk/runadjusterweb/.

#26 Regi says:Greate tutorial. ALso, the opportunity of interactive with your mac worths for the work

#27 Adam Pieniazek says:Great tip, though like Si, I’d love to see a way to enable/disable showing hidden files per folder or per hierarchy.
If anyone knows how to do so, please send me an e-mail (mylastname.myfirstname@gmail.com). I’ll hook you up with a shout-out on my blog or whatever for the favor!
Leave a reply