What Characters Are Not Allowed in File Names?

Perm url with updates: http://xahlee.org/mswin/allowed_chars_in_file_names.html

What Characters Are Not Allowed in File Names?

Xah Lee, 2009-06-03, 2010-07-10

This page tells you which characters are not allowed in Windows or Mac.

Mac OS X uses HFS+ file system, Windows use NTFS. Both encode file names using UTF-16, although the encoding scheme is a bit different. Both also allow a max of 255 unicode chars in file name.

Chars Not Allowed On Windows

Windows's NTFS does not allow the following chars:

 / \ : *  ? " < > |

Chars Not Allowed On Mac

In Mac OS X, you cannot use the colon “:”.

In practice, this means, when you have files with a lot of these chars, you'll have problems transfer it from Mac to Windows. Depending on what tool you use to transfer the file, the tool may stop dead, or change the file name in different ways.

You may think that these weird chars doesn't happen in practice. Actually, they do.

For examples, Adium chat client, save its chat log's filenames like this:

233598025 (2004|10|29).html

Note that the “|” char is not allowed on Windows.

The chars ? / " * may also happen often, such as arbitrary webpages you saved from online over the years, some math files names may use the asterisk “*” and the slash “/” as part of the math formula in the file name, your mom may saved files with question mark and slashes in them, etc.

You may think a few file name screwup is ok. True. However, some critical places matters. For example, saved html files have local links that relies on correct file names. And, for programing systems to work (database, language libraries, code repositories, etc), correct file names is critical.

Unprintable Chars, Chinese, Unicode Chars...

For some other practical issues, see: Mac and Windows File Conversion.

For Perl Scripts that lets you know which files have bad names, see: Perl Scripts For Mac/Windows File Moving.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs