Search This Blog

Saturday 12 June 2010

Mac: Create a hidden folder

You can create a folder that is hidden from the default Finder GUI view by taking advantage of Mac OS X’s unix underpinnings, here’s how:

Create the secret folder

* Launch the Terminal (located in /Applications/Utilities)
* At the command line, type:
mkdir .hiddenfolder
Feel free to replace the name hiddenfolder with anything else, leaving spaces and special characters out of the name will make it easier to deal with in the future.

Access the secret folder

* Now click back to the Finder, and hit Command+Shift+G to bring up the ‘Go to Folder’ dialog box
* Type in the full path to the folder you just created, replacing ‘username’ and ‘hiddenfolder’ with your username and folder name, respectively:
/users/username/.hiddenfolder/
secret folder mac os x
* Your hidden folder will now be opened in the Finder, you can drag and drop whatever you want into the directory

Making existing folders hidden and making hidden folders visible again

You can actually make any folder invisible from the Finder (and most apps) just by adding a period to the front of the name, you can do this with existing folders via the command line:
mv Folder .Folder
And you can make any invisible or hidden folder visible again by reversing this and removing the period from the front:
mv .Folder Folder
Note that you can’t enter a period in front of a folder or file name in the Mac OS X Finder, if you try you will be presented with this dialogue box telling you the dot “.” is reserved for the Mac OS X system software:
mac name reserved for the system

Setting Mac OS X to display hidden folders

You can actually set Mac OS X to display hidden files by issuing a command in the Terminal. This will expose your hidden folder completely within the Finder, but you’ll also see tons of other important system files and folders. This is generally not recommended to keep activated as it is both confusing to many users and it makes it easy to accidentally delete important files.

Notes on hidden folders

Remember that these folders are not hidden completely, they are just not visible from the Mac OS X Finder. Many applications won’t see the folder either, but various FTP programs like Transmit have the option to show invisible files and the folder would be visible to those applications. Likewise, the folder would always be visible via the command line to anyone who typed the ls command and added the -a flag, signifying to display all files, like so: ls -a
If you have Apple’s Developer Tools installed you can use a utility called ’setfile’ which allows you to set any directory or file as invisible, you can read more about hiding files and folders with setfile in Mac OS X, but the limitations on visibility are practically identical to the above technique: file is invisible from the Finder but visible with ls -a or certain applications.