Sunday, 14 April 2013

Easiest way to hide and unhide folders on Mac

Hiding and unhiding folders in Windows is pretty easy. You get an option in Folder options in Explorer. You don't have any such thing in Mac's Finder and that's why you got resort to Terminal commands for it.

hide-unhide-folder-mac

Hiding and revealing folders

Like I said, you got to use Terminal for this, so open Terminal.app from Launchpad or search on Spotlight.
Once it's open, paste this command and hit return.

defaults write com.apple.finder AppleShowAllFiles -bool true

This will reveal all hidden folders in your Mac. But you won't see the results yet. You need to restart Finder to see the effect. To restart Finder, enter this command into Terminal.

killall Finder

You'll now be able to see the hidden folders and files, their icons look faded and little different from normal folders/files.

To revert back, or hide folders – enter the same command you entered in the beginning, changing TRUE to FALSE, that is:

defaults write com.apple.finder AppleShowAllFiles -bool false

You need to enter killall Finder again to restart Finder once again.

Now how would you remember these commands, the next time you want to see hidden files? There's a workaround for that too.

We'll create a file called .bash_profile in the home folder of Mac. .bash_profile contains your preferences, aliases etc.

  1. Open Terminal and type touch ~/.bash_profile
  2. Next, open -e .bash_profile
  3. Once the file is open in Textedit, copy and paste this snippet into the file.
    #reveal hidden folders in finder  alias revealfol='defaults write com.apple.finder AppleShowAllFiles -bool true  killall Finder'  #hide folders in finder  alias hidefol='defaults write com.apple.finder AppleShowAllFiles -bool false  killall Finder'
  4. Save the file and quit the app.
  5. In terminal, type source .bash_profile
  6. And you're done.

What we have done a while ago is, create aliases for commands used for hiding and revealing folders. The aliases are revealfol and hidefol.

So, now if you typerevealfol in Terminal, it will reveal hidden folders for you.hidefol will of course hide the folders, like you expected.

Hide existing folders

Let's say you want to create a hidden folder or want to hide a folder you already created – it's pretty easy.

All you need to do is rename the folder or file, by putting a dot (.) before it.

This works because OS X hides all files/folders whose name starts with a dot. They're called dotfiles.

To rename a existing folder in Mac, open Terminal and type

mv ~/Documents/secrets.txt ~/Documents/.secrets.txt

In the above command, the first argument should be the original path of file and second argument should the path of renamed file (same name with dot before it).

That's all. If you're a developer or someone who messes with this kind of stuff, you must have already knew this.

This tutorial was more intended for beginners. :)

-- This Post Easiest way to hide and unhide folders on Mac is Published on Devils Workshop .





ifttt
Put the internet to work for you. via Personal Recipe 796541

No comments:

Post a Comment