Paolino.me

  • Random
  • Archive
  • RSS
  • Ask me anything

Hide specific folders from the Finder

Update

I hate cluttering my Mac, and cringe every time I see a desktop full of stuff. So, you can probably tell how much I dislike when applications put their stuff in my candid Documents folder. 1

Fortunately though, Mac OS X features a way to hide them from the Finder. If you ever tried to list the root of your hard drive from the terminal, you probably noticed that it is quite different from what the Finder displays:

Root folder as seen in the Finder

$ ls /
Applications/   Developer/
Library/        Network/
System/         Users/
Volumes/        bin/
cores/          dev/
home/           net/
private/        sbin/
usr/            etc@
mach_kernel     tmp@
var@

What’s going on?

Mac OS X’s filesystem stores a series of attributes along with every file and folder. Other parts of the system, like the Finder, are cued by these attributes to display and handle the file correctly. The complete list of attributes is available here. The one we are interested in, Invisible (also represented by a V), determines the visibility of a folder in the Finder, contributing to the overall simplicity of the operating system. If you have Xcode installed on your machine it’s easy to check it and set it thanks to two command line tools, GetFileInfo and SetFile.

GetFileInfo will return the string of all possible attributes, with uppercase letters representing on, and lowercase representing off. For example, the following means that `/private“ is an Invisible folder, because the V attribute is set.

$ GetFileInfo /private
directory: "/private"
attributes: aVbstclinmedz
created: 01/26/2010 10:27:05
modified: 01/26/2010 10:42:18

Thanks to SetFile we can apply this attribute to every folder we please.2 This is quite handy to cleanup ~/Documents from those nasty folders created by games and badly ported programs, without losing our crucial savegames or preference files. The syntax is simple:

 SetFile -a "V" <directories>

For example (do not copy and paste it), yesterday I did this:

$ cd ~/Documents
$ SetFile -a "V" Aspyr "BIT.TRIP BEAT" "Civilization IV" "Civilization IV Beyond the Sword" "Civilization IV Warlords"

That applied the Invisible attribute to all the listed directories. I then restarted the Dock to update the Documents’ stack:

$ killall Dock

Bye bye, ugly folders!

Just in case you will want to make the hidden folders visible again, use SetFile as before, replacing "V" with a lowercase "v", like this:

SetFile -a "v" <directories>

Update: Turns out that Mac OS X provides a slightly simpler solution since 10.5:

chflags hidden <directories>

to hide the <directories> and

chflags nohidden <directories>

to unhide them.


  1. not every program that uses the Documents folder is inherently bad. Papers, iChat, and Colloquy are great examples of exactly the opposite: they use Documents to save only informations relevant to humans. ↩

  2. remember to be careful applying attributes to files and folders. While Invisible is handy in some context, other attributes can be quite dangerous. ↩

    • #Mac OS X
    • #Tips and Tricks
  • 10 months ago
  • Permalink
  • Share
    Tweet

Archive, a button for Apple Mail

screenshot

Enough said.

    • #Gmail
    • #Mail.app
    • #Mac OS X
  • 1 year ago
  • 1
  • Permalink
  • Share
    Tweet

View Source in TextMate for Safari

Have you ever had the need to check the source of the current page in Safari, only to discover this ugly little window that doesn’t do any kind of syntax highlighting?

Current ugly view source window

Wouldn’t be neat to open it in TextMate instead? And wouldn’t be even more neat to have it as an item in a Safari menu? Yes? Ok, so let’s create a custom service!1

First start Automator, select the “Service” template and add the “Run Applescript” action. Then copy and paste the following script in the action’s text area.

This script will automatically fetch the URL and title from the frontmost page in Safari, save the page as a temporary file, and open it in TextMate.

Since the script uses Safari’s AppleScript interface to fetch the necessary information, it doesn’t need any prior info from the browser. So let’s tell Automator that:

Save and you’re done. Enjoy it.


Note that with this technique you can create all the custom Services you need, and even assign them keyboard shortcuts.

To do that, head for the Keyboard panel in System Preferences and let the following picture speak for me.

Keyboard Shortcuts preferences


  1. if you don’t want to do this work, I have done it for you. Download the service, extract it in ~/Library/Services and restart Safari. ↩

    • #Safari
    • #TextMate
    • #Programming
    • #Scripts
    • #Mac OS X
  • 1 year ago
  • 17
  • Permalink
  • Share
    Tweet

Pages

  • About

Elsewhere

  • @paolino on Twitter
  • crmne on Flickr
  • crmne on Pinboard
  • crmne on Last.fm
  • theabstraktor on Soundcloud
  • paolino on Foursquare
  • crmne on Gowalla
  • Google
  • Linkedin Profile
  • earcar on github

Twitter

loading tweets…

I Dig These Posts

  • Post via dariusmonsef
    I haven’t been drunk in 3 years... and I’ve been partying way more than you.

    I had my last drink of alcohol 3 years ago and it’s been a...

    Post via dariusmonsef
  • Photo via wolframalpha

    jtotheizzoe:

    Mind-Melter of the Day

    It turns out that if you divide 1 by 998,001 you get all three-digit numbers from 000 to 999 in order.

    Photo via wolframalpha
  • Post via soundcloud
    HTML5 is ready for the prime time

    See this lovely widget here, well today we’re proud to officially announce that we are switching over...

    Post via soundcloud
  • Photoset via laughingsquid

    Dig Dug to China by Phil Jones

    Photoset via laughingsquid
See more →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

© 2012 Carmine Paolino. Effector Theme by Carlo Franco.

Powered by Tumblr