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)

  • Which file names to you want to change to .filename? – nohillside May 27 '15 at 8:43
  • For example, applications, text files. If possible, even folders. Like maybe change "secret.txt" to "._secret.txt" and open it through terminal. with showallfiles set to YES, i can see .filename files. However not ._filename Is it safe to do ._? I might need to unhide it as well – John K May 27 '15 at 8:46
  • You can name your own files however you want to (well, mostly at least). Renaming files provided or required by the OS and/or applications will break things though – nohillside May 27 '15 at 9:36
  • @patrix so it is unsafe to hide files by putting ._ before them? If yes, is there another way to hide files even from AppleShowAllFiles – John K May 27 '15 at 9:37
  • It's unsafe to rename system- or application-provided files in any way (e.g. if you rename your Library folder to ._Library, you better have a second account configured or know how to use single user mode if you want to log in again). – nohillside May 27 '15 at 11:16

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.

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

    on run {input, parameters}
        (* Your script goes here *)
        return input
    end run


    on run {input, parameters}
            repeat with currentfile in input
                    do shell script "chflags hidden " & quoted form of POSIX path of currentfile
                end try
            end repeat
        end try
        return input
    end run
  7. Save service as "Set Hidden Flag".
  8. 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 " & quoted form of POSIX path of current file


do shell script "chflags nohidden " & 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?

  • Also using zip tools or other copies to and from non HFS disks will merge undergo the ._ files – mmmmmm May 27 '15 at 10:09
  • Thanks. The solution then is to make a service that hides them. And sudo ls shows hidden files as well? – John K May 27 '15 at 10:22
  • @Mark: I was thinking if someone executed dot_clean -n is an effort to clean their folders. This command deletes each dot underbar file if there is no matching native file. All of TheBro21's files would be gone. – David Anderson May 27 '15 at 10:26
  • Yes I was just adding other cases where he would lose files – mmmmmm May 27 '15 at 10:35
  • @TheBro21 The solution is not to do that you will corrupt data using ._ files – mmmmmm May 27 '15 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .