FAQ
- How do I show hidden files in the Mac OS X Finder
- What are .AppleSingle and .AppleDouble files and folders?
- Why do I see “short names” from Windows for some files? (copied to a file server from a Mac)
- How do I unlock files (in bulk) on the Mac
How do I show hidden files in the Mac OS X Finder?
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
But this only controls showing “dot” files (like .git). Finder Info might also exist and have the hidden bit set (FinderInfo came from the classic Mac OS system). Or, an ACL might exist that doesn’t allow browsing for the current user. Files with a ‘@’ appended to the file mode means “this file has extended attributes”, and if there’s a ‘+’ appended, the file has an ACL. You can show the size and kind of the extended attributes with a ‘@’ parameter to ls, and you can show specific FinderInfo attributes in a friendlier fashion with a ‘O’ parameter.
bfitzair:~ ls -l@Oed /Users/bfitz
...
drwx------@ 41 bfitz staff hidden 1394 Sep 23 21:03 Library
com.apple.FinderInfo 32
0: group:everyone deny delete
...
You can manipulate some flags with chflags
chflags nohidden /path/to/file
or you can remove the FinderInfo from extended attributes with
xattr -d com.apple.FinderInfo /path/to/file
You can manipulate ACLs with chmod. It’s moderately complicated to edit them (see the man page for chmod), but you can nuke one by using the -N
sudo chmod -N /path/to/file
What are .AppleSingle and .AppleDouble files and folders?
These are files (or files in folders) that preserve Mac resource forks and extended attributes that cannot be otherwise preserved on the file system. For example, if you copy Mac files to a NFS or SMB file server volume, the Mac will by default create these for files with resource forks or extended attributes.
If you don’t ever want this, you can disable this
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
This might be the drastic fix you need, but you’ll be unable to save classic Mac files (which generally have resource forks) or you’ll lose file attributes that you might actually want.
http://en.wikipedia.org/wiki/AppleSingle_and_AppleDouble_formats
AppleSingle combined everything into one file, in a way similar to the older MacBinary. This has an advantage (single file) but a big disadvantage in that the data fork (usually the one most applications care about) is now shrouded inside the AppleSingle file.
AppleDouble separates the data fork and resource fork + finderinfo into two files. In some instances, the second file is stored as ._{filename}. In other cases, it’s stored in .AppleDouble/{filename}.
In times past, I actually wrote code different platforms to work on their file formats (e.g. converting Apple IIgs resource forks to and from Mac resource forks, or to even do the same between Windows and Mac). It’s a lot easier when you have AppleDouble-style layout.
Why do I see “short names” from Windows for some files? (copied to a file server from a Mac)
Windows has a slightly more strict view of what characters can be in a file name. Unix is pretty permissive, and only bans \0 (nul) and ‘/’ (and even the directory separator can be stored in the low-level file system, it’s just a pain to manipulate it if you do that). However, Windows disallows the following characters from being in a leaf name (file or directory)
\ / : * ? " < > |
(the explorer shell also disallows the typing of any “control” character, e.g a character <= \x1F, but these can be used in filenames). The Mac is a lot more permissive; for example, ‘|’ is a legal character in leaf names.
It gets slightly weird due to a compatibility decision in the transition from Mac OS 9 (“Classic Mac”) to Mac OS X. Before Mac OS X, Apple used ‘:’ as the path component separator character. However, Unix uses ‘/’. Apple decided that the file system would continue to use ‘/’, but the Finder would display these as ‘:’. And conversely, any files with ‘/’ characters in them would be stored in the underlying filesystem as ‘:’ characters.
Now, both characters are not legal for Windows. But SMB will accept the full path and store it, which the Mac side can use. Windows, however, doesn’t like seeing a file name with ‘:’ in it, so you get the synthesized short name when you view the file on a Windows machine. This is better than not being able to store files (from the Mac) or work on them (from Windows), but it’s awkward.
The only solution, if you want to work on files conveniently from both operating systems, is to rename files and directories to the legal subset of characters. In most cases, this means using the Windows set of legal characters as the set of allowed characters for file names. Or, you could write your own explorer replacement?
There are further restrictions in Windows using the Win32 API – files can’t be named CON, PRN, AUX, CLOCK$, NUL, COM[0-9], LPT[0-9].
Of course, there are a few files that you should not rename. For example, a file named “Icon\r” (yes, there is a carriage-return character in the filename) is used by the Mac Finder to display a custom icon for a file. For me, at least, the short name for “Icon\r” is “I7CIPB~N”, so they are easy to recognize (the short name algorithm is deterministic, I hope).
And finally, copying these short-name-aliased files with a Windows machine tends to mutate filenames, because many Windows clients don’t use the underlying NT APIs, and so end up garbling things (e.g. copying an Icon\r file to an SMB share with Mac using SMB and then duplicating it to a different SMB server using the Windows explorer changes it to a non-hidden file named “Icon”.
And more finally, we won’t even talk about real file names that have characters outside the limited ASCII/ISO-646 range. These tend to be garbled very easily, for reasons that may or many not be obvious to you (read up on encoding).
How do I unlock files (in bulk) on the Mac?
Assuming you mean “Mac Finder lock bit” and not Unix permissions (which are set with chmod), you use chflags. For example, to unlock recursively (and see what you unlocked), you would do
chflags -v -R nouchg <folder>
and all files rooted at <folder> would be examined and unlocked if needed. The -v flag will print a line for each file/folder that gets unlocked.
This is actually a FreeBSD command and changes “file flags”, which on the Mac has been interpreted to be finder flags. In fact, the man page on Mac OS 10.7.4 and the man page in FreeBSD look very similar (perhaps even identical). A slightly more Mac-specific page can be found at http://ss64.com/osx/chflags.html.