OS X: hide/unhide files and folders

Let’s use ~/Desktop/1.txt and ~/Desktop/1/ for example.

Hide files and folders:

chflags hidden ~/Desktop/1.txt

chflags hidden ~/Desktop/1/

Unhide files and folders:

chflags nohidden ~/Desktop/1.txt

chflags nohidden ~/Desktop/1/

If you installed Apple developer command line tool in Xcode, you can also use the following ones.

Hide files and folders:

setfile -a V ~/Desktop/1.txt

setfile -a V~/Desktop/1/

Unhide files and folders:

setfile -a v ~/Desktop/1.txt

setfile -a v ~/Desktop/1/

It is also true that these two command makes the same effects, so you can simply use any combination of them. For example, use chflags to hide one file and use setfile to unhide it.

Source link: