Allowed characters in filename
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:
- Windows (FAT32, NTFS): Any Unicode except
NUL
,\
,/
,:
,*
,?
,"
,<
,>
,|
. Also, no space character at the start or end, and no period at the end. - Mac(HFS, HFS+): Any valid Unicode except
:
or/
- Linux(ext[2-4]): Any byte except
NUL
or/
so any byte except NUL
, \
, /
, :
, *
, ?
, "
, <
, >
, |
and you can't have files/folders call .
or ..
and no control characters (of course).