Show/Hide Invisible Files in Finder – Automated with AppleScript

For consumers, the Mac is brilliant. The UI is clean, uncluttered, and shows just the right amount of information about files and has a nice Aqua interface. The Finder has been updated through all the releases of OSX and now includes dynamic previews of files, rapid real-time searches of data, and more.

One thing missing in the Finder view though is the visibility of invisible files. Most users wouldn’t bother about this tiny details, but for developers this is essential. We like to change config files, alter application libraries or (say) change a .htaccess file you downloaded. And for that, sometimes we need to view/alter hidden files.  So to make life easier for myself (and others like me out there), here’s a tiny automator that toggles the visibility of invisible files.

What are Invisible Files ?

For those who don’t know, files that are hidden in Mac OS are determined so by preceding the filename with a single period symbol (.). You can actually make any file hidden by doing this.

Toggle Invisible Files Using Terminal

To show invisible files

Open terminal and run the following command ::

defaults write com.apple.Finder AppleShowAllFiles YES

Once that’s done, press option and click on the Finder (in your Dock) and Relaunch the Finder for the changes to take place.

DONE !!

To hide invisible files

Open terminal and run the following command ::

defaults write com.apple.Finder AppleShowAllFiles NO

Again, once that’s done, press option and click on the Finder (in your Dock) and Relaunch the Finder for the changes to take place.

DONE !!

This is pretty easy and straightforward right ? Then why are automating this via AppleScript you ask ? Well, in my case, I have a terrible memory, and do not enjoy googling the terminal command every time I need to toggle it. If you’re like me, here’s what you can do to automate the entire process.

Toggle Invisible Files Automatically Using AppleScript

 The Code ::

tell application “Terminal”
set status to (do shell script “defaults read com.apple.finder AppleShowAllFiles”)
ignoring case
if status is “NO” then
do shell script “defaults write com.apple.finder AppleShowAllFiles YES”
else
do shell script “defaults write com.apple.finder AppleShowAllFiles NO”
end if
end ignoring
try
tell application “Finder” to quit
end try
delay 3
tell application “Finder” to activate
end tell

The Process ::

  1. Copy the code given into your AppleScript Editor on the Mac under Applications > Utilities > AppleScript Editor
  2. Save as application on your hard drive somewhere
  3. Enable the Scripts Menu (if you haven’t already) : http://guides.macrumors.com/Script_Menu
  4. Goto Users/me/Library/Scripts/Applications/Finder (create this folder if its not already there) and copy the application you just generated into the folder.

DONE !! The script is now available in the Scripts menu item on the menu bar whenever you are in the Finder.

Advertisements

Leave a message :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s