110 Comments

Summary:

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 […]

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.
automator_action1.jpg
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

shell_script_showall.jpg

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.
save_as_plugin.jpg

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.
right-click_showhiddenfiles.jpg

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.

  1. You sure this works?
    I keep getting “Workflow Failed”, so have I missed anything?

    Share
  2. 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/

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

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

    Share
  5. or, install MainMenu and have this one click away, along with the handy Repair Disk Permissions

    Share
    1. Main Menu – really simple! =) thanks

      Share
  6. 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.

    Share
  7. I get workflow failed on both as well…

    Share
  8. 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.

    Share
  9. 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”

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

    Share
  11. Replacing newline with ‘;’ works:

    defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder

    Share
  12. 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.

    Share
  13. [...] post is mostly for me to remember where I can find that article on showing hidden files in OS X, since it’s a pain in the ass to do. Technorati Tags: [...]

    Share
  14. Quicksilver has a “Run command in Shell” command, so you can also set up a trigger for that extra speed boost.

    Share
  15. 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.

    Share
  16. [...] Löysin tuossa TheAppleBlogia lukiessani kiintoisan vinkin. Kyseessä on pari Automator-scriptiä, joilla Finderin saa näyttämään ja piilottamaan piilotiedostot. Ei mikään niin kauhean hyvä tapa, mutta toimiva. Linkki: Show/Hide Hidden Files [...]

    Share
  17. “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.

    Share
  18. This is an awesome tip. Thanks!

    Share
  19. 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?

    Share
  20. i love apple and people who share skills! thanks for tip. very usefull

    Share
  21. 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

    Share
  22. “defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder” … that stops the newline also.

    Share
  23. I used the osascript to ensure that the folders I currently have open will reappear correctly.

    defaults write com.apple.finder AppleShowAllFiles FALSE
    osascript -e 'tell application "Finder" to quit';
    osascript -e 'tell application "Finder" to activate';

    Share
  24. i am VERY angry at this
    i can not make the hidden files disappear again
    can someone please help me?

    Share
  25. Promitheas13 Friday, May 2, 2008

    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';

    Share
  26. Works like a charm. Thank you.

    I was tired of looking up the command everytime I needed to make visible hidden files.

    Share
  27. 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/.

    Share
  28. Greate tutorial. ALso, the opportunity of interactive with your mac worths for the work

    Share
  29. [...] task was to make a little Automater script for hiding and showing hidden files and folders in the [...]

    Share
  30. 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!

    Share
  31. 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

    Share
  32. I am a new Mac-user [Mac OS X, version 10.5.4] and have tried to follow the instructions regarding Show/Hide Hidden Files by Jason Guthrie on April 30, 2007. However, when I open Automator [through Spotlight] the “picture” I get differs from the one in the tutorial: first I have to select a “starting point to open a new workflow” [Custom, Files & Folders, Music & Audio, etc.]. Secondly I have a different listing under “Library” and Automator is not listed there. I also do not have the column “Action”. In short, it all looks different. Can anyone advise me how to follow this tutorial with these differences in mind?
    Thanks in advance,
    KIM

    Share
  33. I tried #21 Mellow

    and it worked very well for me
    It paused a long time the first time it worked with no DESKTOP icons!
    I laughed … and suddenly everything came to in about 45 seconds – FEW

    All I did to swap between show and hide is make one TRUE and one FALSE and put it all into one single AUTOMATOR workflow apple SHELL script and SAVE AS PLUG IN

    Show hidden files
    defaults write com.apple.finder AppleShowAllFiles TRUE
    osascript -e ‘tell application “Finder” to quit';
    osascript -e ‘tell application “Finder” to activate';

    Hide hidden files
    defaults write com.apple.finder AppleShowAllFiles FALSE
    osascript -e ‘tell application “Finder” to quit';
    osascript -e ‘tell application “Finder” to activate';

    now if some one wrote it like this to start with I would not have had to waste 2 minutes of my life!

    Share
  34. Jason – you are my Angel!!!
    Thank you for this solution – I had same shit with .htaccess few weeks ago and found only how to show file and get a lot of “new” item around – with your solution my desk is clean again ;)

    to KIM – I’ve just got same screen as you – just open Automator in default view then go to Utilities>Run Shell Script
    and then same as Jason wrote

    Jason: thank you gain
    KIM: good luck with Mac OS X ;)

    Share
  35. ChrisP #30 thanks for your script. Note that if you copy and paste this into Automator it won’t work because the quotation marks have been changed to in and out marks (maybe by this blog?). It worked when I retyped the ” and ‘ marks.

    Share
  36. [...] files in Windows. A little more difficult on a Mac. Here is a post about how to create a couple scripts to hide/show hidden files using Apple’s Automator. You can just type the commands into the terminal if you rarely [...]

    Share
  37. Thanks for the great tip! One question: if I want to delete the plugin so it no longer appears in the context menu, how do I do this?

    Share
  38. I heard you could archive your ipod on a PC by using the “show hidden files”, and then copy the hidden mp3 files to a hard drive. BTW, I tried this on my iPod and it did not work. No hidden files appeared.

    Share
  39. Hi, this is pretty cool. Thank you. I found the original instructions to work the best. It seems maybe the problems mentioned in some of the earlier comments had to do with their being two lines of code, and when you copied and pasted from the example it saw it as only one line(aka post #14). So copy and paste each individually and it works great. Thanks again to Jason and everyone else.

    Share
  40. Is it possible (I’m quite sure it is) to make the plug-in act as “Toggle Hidden Files”. You would need to ask for the value of com.apple.finder AppleShowAllFiles and toggle it’s value in the script. Does anyone know how to do it?

    Share
    1. i could be write Tuesday, August 18, 2009

      finger?

      Share
  41. [...] Quick Tip: Show/Hide Hidden Files [...]

    Share
  42. Very cool – thanks. I really should take a closer look at Automator.

    Share
  43. Many thanks!! This saved me so much time.

    Thanks again.
    Sanjeev

    Share
  44. Really helpful thanks!

    Share
  45. Pretty cool!
    thanks!

    Share
  46. Once I changed the line breaks this worked like a charm. Thanks for the tutorial!

    Share
  47. Hi Geeks,

    Cheers for the tip. It’s awesome.

    I am a new user of MAC and recently brought a mac bookpro. I really love it.

    I found this really useful.

    Regards,
    S.Kamalarajan
    Senior System Administrator

    Share
  48. this is cool. but when i open automator there is no applications folder in the library. any help please?

    Share
  49. nevermind i figured it out. thank you very much

    Share
  50. I know a lot about PC computers, but MAC is something new… thanks for this information, I’m learning a lot…

    Share
  51. [...] .htaccess files are hidden in the finder window, which makes it difficult when you want to edit on of them (or make sure you have them!). Here’s a great tutorial to set up a way to view those files in the finder window: Quick Tip: Show/Hide Hidden Files. [...]

    Share
  52. Good work mate.It’s quite useful for some like me who just switched from crap Windows to MAC.

    Share
  53. [...] .htaccess files are hidden in the finder window, which makes it difficult when you want to edit on of them (or make sure you have them!). Here’s a great tutorial to set up a way to view those files in the finder window: Quick Tip: Show/Hide Hidden Files. [...]

    Share
  54. hardwarekid Monday, June 15, 2009

    Thanks! works great in 10.5.7!

    Share
  55. Thats one good hack..!!

    Cheers M8!! Keep coming with other tips too…!!

    Share
  56. Great hack! Now you can get that pesky trash folder into the Finder’s sidebar (I’m working with two monster screens and I’ve to travel all the way to the right to peek into it (yeah, I know, luxury problem ;-).
    I got this from Screenmates:
    drag the /Users/Home/.Trash hidden folder to the sidebar and bingo!

    Thanx mate.

    Share
  57. perfect!

    Thanks!!

    Share
  58. thanks a lot! you solved a lot of my problems in one go :)

    Share
  59. Great post thanks.

    Recently bought a macbook pro and have been struggling with this bad boy!

    Share
  60. what does he mean when he says “simply edit the above workflow by substituting “FALSE” for “TRUE”

    Share
  61. [...] Quick Tip: Show/Hide Hidden Files [...]

    Share
  62. Hi,
    how do I remove from Automator the entries created for ShowHiddenFiles and HideHiddenFiles? I think I like better the once in a while option to use terminal.

    thanks

    Share
  63. Brilliant. Worked great. Thanks.

    Share
  64. works perfectly, so simple and took 30 seconds,
    thanks so much! :)

    Share
  65. This worked great, thank you. But how do I now undo it? It is very important that I put it back to how it was.

    Share
    1. just repeat the same process but instead of writing TRUE write FALSE.
      it’s in the 3rd paragraph in the post:

      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.

      Share
  66. What I was asking was hot to remove the two options from the menu. So when you right click the desktop, hover more, then automator it doesnt show, “show hidden files” and hide hidden files. But I solved it.

    open finder>go>go to folder…>~/Library/Workflows/Applications/Finder>delete the two files.

    Share
  67. I had this working on my system until I upgraded to Mac OS 10.6 Snow Leopard. Now, I don’t get the contextual menu listing Automator workflows. Any thoughts?

    Share
    1. Hi!!
      I have the same problem!
      Just upgraded to Snow Leopard and I don’t get the contextual menu listing Automator workflows!!

      Did you manage to recover them?

      Someone recommended me this third party app
      KavaServices
      I haven`t really tried it.

      Please do let me know if you can use it again.

      Share
    2. Hello Again!
      I manage to get this working
      check out this link
      http://www.reynoldsftw.com/2009/08/automator-and-finder-interactions-in-os-x-10-6/

      It turns out, you must right click a file or folder and then you’ll get the automator workflow!

      Share
    3. Mark, I have the same problem.

      Tivo, I have been working on this for over an hour and haven’t figured out how to get this to work through automator. It seems like you have it figured out. Could you explain EXACTLY what you did? I am extremely frustrated as it seems like this should be so simple and there’s no help on the net. I can’t even get any of those Terminal commands I’ve found around the net to work, so I really need this explained step-by-step! Thanks for any help.

      Share
    4. Tivo, nevermind. I finally posted an e-mail to the Automator mailing list, and somebody responded with a post that helped me figure out how to do it.

      1) Open Automator
      2) Select “Service” and “Choose”
      3) Where it says “Service receives selected…” pick “files or folders” from the drop-down menu, then “in…” pick “Finder” from the drop-down menu.
      4) To the left, in the big list of actions, pick “Run Shell Script” and drag it and drop it into the empty pane to build the workflow.
      5) In the box where you type, delete “cat” and cut-and-paste “defaults write com.apple.finder AppleShowAllFiles TRUE
      killall Finder”
      6) Go File>Save As… and name it whatever you want (like “Show Hidden Files”).
      7) To get it to work, right-click on any folder and choose “Show Hidden Files” or whatever you named your workflow.
      8) To hide hidden files, repeat steps 1-7, except in the code, change “TRUE” to “FALSE” and name your workflow differently (i.e. “Hide Hidden Files”)

      Hopefully this helps some other people.

      Share
      1. Thanks Melanie this worked perfect

        Share
  68. Wow… that was sweet! easy as eating chips. I found the original post to be fantastic and it was easy to follow and it work like a charm.

    Share
  69. OMG, That was an awesome trick. Thank you very much.
    I have a question about virtual box on mac : I have installed windows xp in virtual box on mac, but USP ports doesn’t work.
    Do you know how I could enable them???

    Thank you so much

    Share
  70. Wow – thanks! Actually got me using Automator. I’ve looked at that thing before, never figured out how to use it, though I knew I wanted to.

    Quick and VERY useful. I tried the other options, but the original worked best for me.

    Share
  71. Update – once I tried this a couple of times, the loss of my current Finder windows really bothered me. So I searched around, and found AppleScript for quitting/reactivating the Finder.

    Preserving the current Finder windows is nice.

    Now my Automator script looks like this:

    [ Run Shell Script - has this: ]
    defaults write com.apple.finder AppleShowAllFiles FALSE

    [ Run AppleScript - has this: ]
    activate application “Finder” –gives Finder focus

    tell application “Finder”
    quit
    delay 2 –finder needs some time to save its state
    activate application “Finder” –restart Finder
    end tell

    Hope this helps someone!

    Share
  72. My parents used to torture me as a child. ,

    Share
  73. Hi, this method works perfectly. However it does not seem to apply immediately even when i close all the finder windows. It only shows all the hidden files when i re-start my mackbook. Any ideas?

    Share
  74. Here’s how to make a shell script to do this for you if you prefer just using Terminal
    http://macmartine.com/blog/2009/11/shell-script-to-showhide-hidden-files-on-os-x.html

    Share
  75. Good freeware application for http://code.google.com/p/hide-unhide

    Share
  76. great fix!!! now i can see everything

    Share
  77. Thank you so much!

    Share
  78. Yes, nice fix, thanks. But it has the strange effect on my Mac (OSX 10.4.11) of making ALL (and I mean all) my file and folder icons kind of dimmed or faded? I can still see them ok, but they’re not bright shining icons like they were before!

    It’s a bit like looking at the icons through a cataract! (I hope I’m not getting one…)

    Share
  79. Elegant solution, perfect!

    Share
  80. Anthony Lopez Sunday, April 11, 2010

    This didn’t work for me the first time, but it is because I copied and pasted directly from this page, not realizing that there is a line break, as someone else mentioned. I had my code all on one line, which is wrong. That is, the code should have TWO lines exactly as shown above, and here:

    defaults write com.apple.finder AppleShowAllFiles TRUE
    killall Finder

    Then it worked perfectly – thanks!

    Share
  81. I used time machine to move all of my preferences/files into 10.6.3 from 10.4.X and when I try to run the new script in Automator I get this message:

    ACTION FAILED: defaults[258:60f] Unexpected argument killall; leaving defaults unchanged. (1)

    Any idea what is going on?

    Share
  82. I used time machine to move all of my preferences/files into 10.6.3 from 10.4.X and when I try to run the new script in Automator I get this message:

    ACTION FAILED: defaults[258:60f] Unexpected argument killall; leaving defaults unchanged. (1)

    Any idea what is going on?

    p.s. I had the “show hidden files” automator running in 10.4 which it carried over into 10.6 and now I want to make it go away. That’s the problem I’m having.

    Share
    1. Alex, I went from 10.4 to 10.6 also, and they changed Automator enough to where you can’t do things the same way as you used to. If you look at my post a little ways up this page from March 21, 2010, I explain the way I found out how to get this script to run in the new Automator. Just follow it step-by-step and it should work. Hope this helps.

      Share
    2. Okay, sorry I didn’t notice your “P.S.” until now. I don’t know how to make that error stop, except maybe if you create the new script, it will cause the error to stop. Maybe just wishful thinking.

      Share
      1. This widget for Mac works very well to show and hide htaccess files…

        http://www.apple.com/downloads/dashboard/developer/hiddenfiles.html

        I was unable to get the shell script to work on snow Leopard Melanie and kept searching for a solution and found this widget! It’s fantastic!

        Share
  83. Thanks Melanie and Jessica! I couldn’t get Automator to work for me either, but the widget is great!

    Thanks again :)

    Share
    1. You’re welcome. I wonder why you two weren’t able to get it to work. I simply typed the EXACT steps I used and it works just fine for me. Who knows. I’m glad you found something else that works at least. This was a big hassle for me when I was trying to figure it out.

      Share
  84. The above procedure doesn’t work with Snow Leop-ard. There is no “Save As Plug-in” option available.

    Nor is Applications listed in the Library.

    Share
    1. It worked fine in Snow Leopard for me. Here’s what I did:

      – started automator
      – choose work flow as the template type
      – clicked Utilities on the far left window
      – dragged then dropped Run Shell Script into Workflow window
      – delete the “cat” text and then paste in the:

      defaults write com.apple.finder AppleShowAllFiles TRUE
      killall Finder

      – File –> Save As
      – name it and choose Application as the type
      – That’s it!

      Share
  85. Hi…
    i can’t find save as plugin… in automator menu…
    what am I missing? is this only for older version of automator?

    Thanks,
    Robert

    Share
  86. [...] You can place the SDK anywhere you like. I’ve seen many suggest placing the Android SDK in the  /Developer folder.  I leave this directory to the apple developer tools and place SDKs in the more traditional /usr/lib. The /usr/lib directory is hidden by default. You will need to show hidden files to see it in the finder. If you develop on the Mac, you probably know how to show/hide invisible files, if not I like this method: Show/Hide Hidden Files. [...]

    Share
  87. I was having trouble with Automator on my laptop and found this much MUCH simpler alternative using Terminal…

    http://il.youtube.com/watch?v=lBCaPLrN5Mw

    Share
  88. Thanks for this writeup! You should update it (or provide new instructions) for the changes to Automator right-click menu functionality in Snow Leopard.

    I found the following comment to be useful, that describes the changes.
    http://forums.macrumors.com/showpost.php?p=8713076&postcount=3

    The steps to get the Automator script right-click menu items back in Snow Leopard are:

    1. Open Automater.
    2. Choose the ‘Service’ template
    3. Specify that the service receives input from ‘files or folders’ in application ‘Finder’
    4. Find and Drag the ‘Run Shell Script’ action from the Actions sidebar.
    5. Paste in the commands mentioned in the original instructions.
    6. Save the script according to the original instructions.
    7. Repeat these instructions for both ‘Show Hidden Files’ and ‘Hide Hidden Files’.

    To see it in action just right click on any file or folder in finder, and there will be a new ‘Services’ menu > Hide Hidden Files, Show Hidden Files.

    Note you can also make this option appear in the MAIN application Services menu (eg, Finder > Services > Hide Hidden Files). In step #3, choose ‘no input’ instead of ‘files or folders’.

    Share
  89. When I open Automator, what template do i use???

    Share
  90. cmd click not working… don’t know why i cannot get the pop up box? please help

    Share
  91. This works great, but two things happened. The script showed the hidden files, but also show how much used/free space is on my local drives. I was able to run the script to now show the hidden files, but my local drives still know the used/free space. How do I get rid of that?

    Share
  92. If you want to hide some files on your Mac from curious eyes, then there is a solution available. It is called UberMask. It allows to hide/show files with a single keystroke. Available for test here: http://www.novamedia.de/en/mac-ubermask.html

    Share
  93. Ok, so I followed these steps, and now when I go into my Documents Folder..there’s nothing there. Have all my Documents been deleted??

    Share
  94. I followed these steps. When I went into Finder > Documents…all my Documents are now missing. Are my documents deleted forever?

    Share
  95. Someone (nikolar) had asked about this in the other comment section but for some reason I wasn’t able to reply to it. I retooled the two services into one that toggles between showing and hiding the hidden files:

    VALUE=$(defaults read com.apple.finder AppleShowAllFiles).
    if [ "$VALUE" = FALSE ]; then.
    defaults write com.apple.finder AppleShowAllFiles TRUE.
    else
    defaults write com.apple.finder AppleShowAllFiles FALSE.
    fi
    osascript -e ‘tell application “Finder” to quit';.
    osascript -e ‘tell application “Finder” to activate';.

    Share

Comments have been disabled for this post