I'm trying to make a Python script that creates a hidden folder for a specific file I'm creating across any platform.

I'm aware you can do this easily with Linux by placing "." as the beginning of a file or folder name, but haven't found anything saying that you can do the same with MacOS. I don't have a MacOS system to test with, which leaves me at a roadblock.

Would I be able to just create a directory and/or file named ".file" like in Linux systems, or would I need to use the chflags method that I see everywhere I look?


1 Answer 1


Hidden filenames is a feature of the Unix shells and of the other standard Unix tools, not of any particular filesystem implementation (a "hidden" name is just a name starting with a dot).

macOS, since it is a Unix operating system, supports hidden filenames just like Linux or any other Unix.

Example on macOS:

$ touch file .hidden_file
$ ls
$ ls -a
.       ..      .hidden_file    file
  • Thank you for the help! I was looking everywhere and couldn't find if that was true. Apr 7, 2019 at 8:24
  • @EarthToAccess If it wasn't true, it would be virtually impossible to run basic shell scripts written for Linux on macOS. As it turns out, as long as a script is otherwise portable, scripts works the same on any Unix with regards to these filenames.
    – Kusalananda
    Apr 7, 2019 at 8:32
  • Oh, neat! I genuinely didn't know that. I'll learn to keep this in mind for any other Unix question like this I have in the future. Apr 7, 2019 at 8:44
  • Is it true of the finder, and other GUI tools? Apr 7, 2019 at 9:49
  • 1
    @ctrl-alt-delor A file or directory with a hidden name will not show up in the Finder or in macOS's file selection dialogs. I'm sure there are exceptions to this (as it's bound to be on non-macOS systems too).
    – Kusalananda
    Apr 7, 2019 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.