MacOS – What would cause normal files to be hidden from the Finder but not the terminal

findermacospermission

I exported a set of photos from my wife's computer to mine over a WiFi share. I opened the directory in Finder and it said that there were 0 files. I know I've seen the Finder lag before on recognizing files in the folder, but this wasn't one of those cases.

I went into the terminal and I could see all the files were there and these were not "UNIX hidden" filenames (i.e. prefixed with a period). However, I did notice that they had extended attributes for com.apple.FinderInfo and com.apple.quarantine. I removed both of these attributes figuring that might be it and now the files were simply -rw------- permissioned. I even chmod'd them to allow group/other permissions, however, they STILL didn't appear in the Finder. If I attempted to use the command open IMG_0123.JPG from the terminal (both before and after every action I tried), they would happily appear in the Preview application. I was finally able to see them after I copied them to a FAT32 partition and then copied them back.

FWIW, the files were copied between Mavericks machines.

So my question is why would these files not appear in the Finder?

Best Answer

On BSD you have a file flag that allows you to hide the file.

$ chflags hidden path/to/file to hide a file.

You can see the flag with ls -lO

$ ls -Ol foo.txt
-rw-r--r-- 1 harry staff - 0 17 Jun 15:57 foo.txt
$ chflags hidden foo.txt
$ ls -Ol foo.txt
-rw-r--r-- 1 harry staff hidden 0 17 Jun 15:57 foo.txt