How to make hidden files/folders and show hidden files/folders on Mac OS X

On Mac OS, the file/folder bearing the name started by a dot (.) or the default system file are hidden. Sometimes when we need to work with these hidden file, the best way is to adjust them to be available for more convenience when working.

There are many ways to make it, in this article, we will instruct you to use some popular solutions:

Hide/ Display the hidden file/folder on Mac OS X

Solution 1: Use Terminal

This is the easiest way to display the hidden file/folder. You only need to open Terminal apps (Applications/Utilities) then copy and paste the following command and press Enter.

defaults write com.apple.finder AppleShowAllFiles -bool YES

However, we need to restart Finder to activate the code. Also copy the below command and paste into Terminal and run.

killall Finder

Now the hidden file/folder is displayed. Whenever you want to hide it, run the similar command above but change the value from YES to NO.

defaults write com.apple.finder AppleShowAllFiles -bool NO

Then restart Finder for completion.

Solution 2: Use shortcut menu to change hidden/display settings

For beginning, open Automator (in folder Applications) and choose Service type as follows:

Then choose “Run AppleScript

then copy and paste this code into .. (please note to choose Service files or folders in Finder.app)

set STATUS to (do shell script "defaults read com.apple.finder AppleShowAllFiles")
if STATUS is equal to "0" then
	#display dialog "hide -> show"
	do shell script "defaults write com.apple.finder AppleShowAllFiles -bool YES"
else
	#display dialog "show -> hide"
	do shell script "defaults write com.apple.finder AppleShowAllFiles -bool NO"
end if
do shell script "killall Finder"

you may choose “Run Shell Script” with the code:

STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == YES ]; 
then
    defaults write com.apple.finder AppleShowAllFiles NO
else
    defaults write com.apple.finder AppleShowAllFiles YES
fi
killall Finder

Then choose menu File -> Save -> insert Toggle Hidden Files

The system will save a service named “Toggle Hidden Files” at~/Library/Services

Now when opening Finder, right-click on the mouse into a file or folder, you will see the menu for hiding or displaying the file appearing as below:

 

Create a hidden file or folder on Mac OS X

On Mac OS, there is no option to set the hidden settings to a file or folder for convenience as on Windows. However it can be done easily by some simple solutions I intend to bring to you here.

Solution 1: Using Terminal

For using Terminal, we have 02 sub-solutions:

1. Create a folder with the name having a dot (.) in the beginning

For this solution, use the following command:

mkdir /path/to/.myfolder

Default, the folder .myfolder is set hidden right after its creation, to see it we need to follow the above instruction..

2. Change the hidden settings for file/folder

After open Terminal, you copy and paste the below command to change the hidden settings for file/folder.

chflags hidden /path/to/your/FolderOrFile

/path/to/your/FolderOrFile is the link to the folder you want to set hidden. If it is not clear enough, you only need to copy chflags hidden and drag the file/folder you want it to be hidden into this and then Enter.

chflags hidden [drag your file or folder here]

If you want to display the file/folder which recently was set hidden, use the following command:

chflags nohidden /path/to/your/FolderOrFile

or use the instructed was as I mentioned above (Hide/Display file/folder on Mac OS X)

Solution 2: Use shortcut menu to change the hidden/displayed mode (for assigned file/folder)

This solution is also by creating a Service (as instructed in the above part) with choosing “Run AppleScript

on run {input}
	set theInput to item 1 of input
	set thePath to POSIX path of theInput
	set question to display dialog "Which option you want to change the file/folder to ?" buttons {"Hide", "Show"} default button 1
	set answer to button returned of question
	if answer is equal to "Hide" then
		do shell script "chflags hidden " & thePath
	else
		do shell script "chflags nohidden " & thePath
	end if
	try
		tell application "Finder" to update items of front window
	end try
end run

Then choose File -> Save -> Insert Change Hidden Flags

Now then when you right-click into a folder/file, you will see the menu as below:

Choose Change Hidden Flags to see the dialogue box requesting for hiding/displaying the selected file/ folder.

Hope you will succeed with our instruction.


Warning: touch(): Utime failed: Operation not permitted in /home/nginx/domains/freesoftwaredl.info/public/blog/wp-content/themes/newsplus/single.php on line 440