Occasionally it may be desirable to hide a folder on your Macβs filesystem, either to keep it away from prying eyes or simply because itβs better not to be able to view some folders that could easily be removed or deleted by accident.
Finder doesnβt have any built-in ways to hide a folder (i.e. with a simple keyboard shortcut or from the Get Info window), and so the recommended method is within Terminal using the chflags command. This tutorial describes how to hide any file or folder in seconds.
Hide a Folder
Follow these steps to hide any folder or file:
1. Open Terminal from theΒ Applications -> Utilities folder or using Spotlight
2. At the Terminal command prompt, type this followed by Enter:
-
chflags hidden <filename or folder>
The folder specified and all itβs contents will disappear from view in Finder, but itβs important to note that the files are still there and have not been deleted. If the filename contains spaces, you may need to put quotes around it, for example:
-
chflags hidden "~/Documents/Hide This Folder"
Rather than type in the whole file path, itβs also possible to enter the chflags command and then drag the file or folder into the open Terminal window which completes the file path for you. This just speeds up the process of entering the file path manually.
It may be necessary to enter the chflags command as the super user if youβre not already logged in as root. To do this, use the sudoΒ command (the βsuper user doΒ commandβ) and enter the root password when prompted.
-
sudo chflags hidden <filename or folder>
The chflags command can be used to change many properties about files. For more complete details on chflags, just type inΒ man chflags at the command prompt to display the manual pages.
Unhide a Folder
Once your folder has been hidden, you might be wondering how to view it again. The simplest way is to use the same terminal command with the nohidden flag as follows:
-
chflags nohidden <filename or folder>
This makes the file reappear in Finder and resets its visibility back to normal.
Using Terminal With Automator
Every time you want to hide or unhide a folder, you could open Terminal and type in the chflags command. However, another perhaps more convenient method is to use Terminal to build an Automator workflow. This lets you create a small app that you can drag and drop files onto to hide, or even as a service to act on Finder items.
One approach to create an application is as follows:
1. Open up Automator and choose workflowΒ to create a new workflow
2. In the Actions pane, search for theΒ Get Specified Finder ItemsΒ item and drag it to the main window
3. In the Actions pane, search for theΒ Run Shell ScriptΒ item and drag it to the main window
4. In the Run Shell Script item, change the Pass input menu to as arguments
5. In the Run Shell Script item, enter the following script commands:
for f in β$@β; do
chflags hidden β$@β
done
Your workflow should look like this:
6. Save the workflow as an application and enter a suitable filename. Your new application will be saved with an Automator icon. You could also save it as a service which would be available in Finderβs Services menu item
7. Now just drag and drop any files onto the Automator app icon to hide them. To unhide them, obviously you canβt drag and drop files already hidden from Finder so youβll have to unhide them manually with the chflags nohidden command from Terminal instead
Before you go
After spending over 20 years working with Macs, both old and new, theres a tool I think would be useful to every Mac owner who is experiencing performance issues.
CleanMyMac is highest rated all-round cleaning app for the Mac, it can quickly diagnose and solve a whole plethora of common (but sometimes tedious to fix) issues at the click of a button. It also just happens to resolve many of the issues covered in the speed up section of this site, so Download CleanMyMac to get your Mac back up to speed today.
Add Comment