Toggle hidden files Finder OS X 10.10 Yosemite
When I needed to create and alter a hidden file I was looking for a way to show those hidden files in the Finder application. There was no such option. Googling further brought me finally to a solution that worked. First I encountered the differences between the OS X versions and now have got a solution that works perfectly for OS X 10.10 Yosemite. And because I thought I would need to show the hidden files more often than this one time, I created a context option so that I can use this at my liking. Just clicking on a file or folder in the Finder application and choosing the option ‘Toggle hidden files’ would be great!
Let’s get started!
Enable (and disable) it through the Terminal
The command to use is the following:
defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder. What it does is setting a property to true, which is false by default. By setting this property to true the hidden files and folders will be shown in the Finder application.
Disabling displaying of hidden files can be done by executing the same command, only then setting the property to
Automating the toggling of hidden files, create a context menu item
At first I created a script to test if toggling would work. For this I read out the property and checked if I is enabled or not. Depending on the enablement I would initiate the command to invert the current setting. My initial script looked like this:
#!/bin/bash # # Script to toggle hide/unhide hidden files in the Finder application. # # Author : Bert van Langen # Created : 21 December 2014 # STATUS=`defaults read com.apple.finder AppleShowAllFiles` if [ $STATUS == 1 ] then defaults write com.apple.finder AppleShowAllFiles -boolean false else defaults write com.apple.finder AppleShowAllFiles -boolean true fi killall Finder
Please note that the script is checking on a boolean
FALSE by checking the status on a
0. To be able to test the script, be sure to set the right permissions.
chmod 700 I set for this (the owner is able to read, write and execute). After the permissions were set executing the script proved that it was working as expected.
To automate the script I used Automator, which is an application distributed with OS X Yosemite (and other versions). The way to get a context menu item Toggle Hidden Files can be achieved by copy and pasting this script in a Automator Service.
- Launch Automator located in the applications
- Select Service as the type of template to use for your new Automator task, and click the Choose button.
- In the Library pane, make sure Actions is selected, then underneath the Library item, click Utilities. This will filter the available workflow types to just those relating to utilities.
- In the filtered list of actions, click Run Shell Script and drag it to the workflow pane.
- At the top of the workflow pane are two drop-down menu items. Set the Service receives selected to ‘files or folders’. Set the in to ‘Finder’.
- Copy the entire shell script command that we created above, and use it to replace any text that may already be present in the Run Shell Script box.
- From the Automator file menu, select “Save,” and then give the service a name. The name you select will appear as the menu item. I call mine Toggle Hidden Files.
- After saving quit the Atomiser
And now, when I get the context menu on a file or folder in the Finder application I have a new context menu item Toggle Hidden Files that does what it says! I’m loving it…