In Linux, you can easily hide a file by appending a “.” to the beginning of the filename. In Mac, you won’t be able to do this.
The solution is simple. All you need is to use the “
1. Open a terminal in Mac (Utilities -> Terminal).
2. Type the command:
chflags hidden /path/to/file
and press Enter. Your file/folder will magically disappear from the scene.
3. To unhide the file/folder, use the command:
chflags nohidden /path/to/file
Hide File/Folder From the Context Menu
With the help of Automator, we can easily create a service to hide your file/folder directly from the context menu.
1. Open Automator. Choose “Services”.
2. For the “Services selected receives” field, select “files or folders” and “Finder”.
3. Next, drag and drop “Run shell script” from the Action to the Workflow section. Select “as arguments” for the Pass Input field. Paste the following script:
for f in "$@" do chflags hidden "$f" done
and save the service as “Hide”.
Now, you should be able to find the “Hide” option in the context menu when you select and right click on a file/folder.
The disadvantage about this script is that you can only use it to hide the file. You won’t be able to use it to unhide the file. To do so, you have to use the terminal.