How-to: Choose a valid filename

The only two invalid characters for macOS filesystems (UFS, HFS+, and HFSX) are slash ('/') and null ('\0')

Text encoding of filenames

macOS supports international unicode characters in filenames, the filename must be normalized to Apple’s "nearly" Unicode NFD (NFD with Apple HFS+ variations).

macOS always uses NFD on its hfs+ filesystem (or even when using FAT on a memory stick).
(The above assumes you are using the POSIX API, not the legacy pre-macOS API.)

Windows XP and Linux do not perform any normalization, they just store the filename as given.

Cross-platform compatibility

The following characters are valid in macOS but should be avoided in filenames if you need compatibility with other operating systems:

: (colon)
\ (back-slash)
¢™$® (Unicode symbols)
. , [ ] { } ( ) ! ; " ' * ? < > | (Punctuation marks)
White space characters such as spaces, tabs, new lines and embedded returns.

Related macOS commands

Cross-platform filename best practices and conventions - Apple Support.
unicode.org - Normalization Form D (NFD).
macOS How To


 
Copyright © 1999-2024 SS64.com
Some rights reserved