Show hidden all files, but hide some I am trying to show all files and hide some. I know about the command:

defaults write com.apple.Finder AppleShowAllFiles -bool YES


But that shows even files that I have hidden with chflags hidden. I want to hide those files. Is it possible to change its name into a ._ file, or is that not safe? I don't want to chflags nohidden manually one by one. Is there a way to do so?



Mac OS X 10.9.5 (Mavericks)
The .filename was intended by unix to represent invisible file names. Even before there was GUI's, the ls command by default would not list these files for normal users. There is no reason you can not add a . prefix to your own file names.

On the other hand, using ._filename seems to be unique to OS X. One use of these filenames is to store addition information regarding files with the same name minus the ._ prefix. OS X even has a special command dot_clean to delete or merge these types of files.  

In my option, I would not risk deliberately using the ._ prefix in my filenames. You may get acceptable results now, but future versions of OS X may interpret such names differently.

For example, let's say you create a file called ._dave. Later could OS X end up creating a file called ._._dave?

Just FYI:
It is possible to create a service that would allow you to set the hidden file flag for highlighted files using the Finder application. The instructions are given below.


Open the Automator application.
From the menu bar choose "File", then "New".
Select "Service" and click "Choose".
Drag the action "Run AppleScript" to where it says "Drag actions or
files here to build your workflow".
Set "Service receives selected text in any application" to
"Service receives selected files or folders in Finder".
Replace the code

on run {input, parameters}

    (* Your script goes here *)

    return input
end run


with

on run {input, parameters}
    try
        repeat with currentfile in input
            try
                do shell script "chflags hidden " &amp; quoted form of POSIX path of currentfile
            end try
        end repeat
    end try
    return input
end run

Save service as "Set Hidden Flag".
Close all Automator windows and quit the Automator application.


The service should have been saved in the ~/Library/Services folder under the name Set Hidden Flag.workflow. If not, move it there.

Now when you highlight one or more files using the Finder application, you can right click and select "Set Hidden Flag" to hide from the Finder application.

A simular service named "Reset Hidden Flag" can be created using the same steps, with the following two exceptions. In step 6, change

do shell script "chflags hidden " &amp; quoted form of POSIX path of current file


to

do shell script "chflags nohidden " &amp; quoted form of POSIX path of current file


In step 7, change to save as "Reset Hidden Files". 

Of course, you can not highlight the hidden files unless the Finder application displays them. To do this see my answer to Hotkey to show hidden files and folders in File Open dialog?