You should start with the Wikipedia Filename page. It has a decent-sized table (Comparison of filename limitations), listing the reserved characters for quite a lot of file systems.
It also has a plethora of other information about each file system, including reserved file names such as CON
under MS-DOS. I mention that only because I was bitten by that once when I shortened an include file from const.h
to con.h
and spent half an hour figuring out why the compiler hung.
Turns out DOS ignored extensions for devices so that con.h
was exactly the same as con
, the input console (meaning, of course, the compiler was waiting for me to type in the header file before it would continue).
OK, so looking at Comparison of file systems if you only care about the main players file systems:
NUL
, \
, /
, :
, *
, ?
, "
, <
, >
, |
. Also, no space character at the start or end, and no period at the end.:
or /
NUL
or /
so any byte except NUL
, \
, /
, :
, *
, ?
, "
, <
, >
, |
and you can't have files/folders call .
or ..
and no control characters (of course).
On Windows OS create a file and give it a invalid character like \
in the filename. As a result you will get a popup with all the invalid characters in a filename.
To be more precise about Mac OS X (now called MacOS) /
in the Finder is interpreted to :
in the Unix file system.
This was done for backward compatibility when Apple moved from Classic Mac OS.
It is legitimate to use a /
in a file name in the Finder, looking at the same file in the terminal it will show up with a :
.
And it works the other way around too: you can't use a /
in a file name with the terminal, but a :
is OK and will show up as a /
in the Finder.
Some applications may be more restrictive and prohibit both characters to avoid confusion or because they kept logic from previous Classic Mac OS or for name compatibility between platforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With