Filename - Reserved Characters and Words

Reserved Characters and Words

All file systems did not always provide the same character set for composing a filename. Before Unicode became a defacto standard, filesystem were mostly working on the basis of a character set depending on the locale, while some new systems permit a filename to be composed of about every character of the Unicode repertoire, with some specific limitations.

Depending on the system, limitation can be provided by the filesystem, by the operating system, by the application, or by the user need of interoperability with other systems.

The basic character set might be limited to a subset of unicode characters, such as a 256 values 8 bit encoding, be based on Unicode character set, or include special bytes sequences which do not form any valid unicode character.

Many file system utilities prohibit control characters from appearing in filenames. In Unix-like file systems the null character, as that is the end-of-string indicator and the path separator / are prohibited.

Some file system utilities prohibit some particular characters from appearing in filenames:

Character Name Reason
/ slash used as a path name component separator in Unix-like, Windows, and Amiga systems. (The MS-DOS command.com shell would consume it as a switch character, but Windows itself always accepts it as a separator.)
\ backslash Also used as a path name component separator in MS-DOS, OS/2 and Windows (where there are few differences between slash and backslash); allowed in Unix filenames, see Note 1
? question mark used as a wildcard in Unix, Windows and AmigaOS; marks a single character. Allowed in Unix filenames, see Note 1
% percent used as a wildcard in RT-11; marks a single character.
* asterisk
or star
used as a wildcard in Unix, MS-DOS, RT-11, VMS and Windows. Marks any sequence of characters (Unix, Windows, later versions of MS-DOS) or any sequence of characters in either the basename or extension (thus "*.*" in early versions of MS-DOS means "all files". Allowed in Unix filenames, see note 1
: colon used to determine the mount point / drive on Windows; used to determine the virtual device or physical device such as a drive on AmigaOS, RT-11 and VMS; used as a pathname separator in classic Mac OS. Doubled after a name on VMS, indicates the DECnet nodename (equivalent to a NetBIOS (Windows networking) hostname preceded by "\\".). Colon is also used in Windows to separate an alternative data stream from the main file.
| vertical bar
or pipe
designates software pipelining in Unix and Windows; allowed in Unix filenames, see Note 1
" quote used to mark beginning and end of filenames containing spaces in Windows, see Note 1
< less than used to redirect input, allowed in Unix filenames, see Note 1
> greater than used to redirect output, allowed in Unix filenames, see Note 1
. period
or dot
allowed but the last occurrence will be interpreted to be the extension separator in VMS, MS-DOS and Windows. In other OSes, usually considered as part of the filename, and more than one period (full stop) may be allowed.
space
allowed (apart MS-DOS) but the space is also used as a parameter separator in command line applications. This can be solved by quoting, but typing quotes around the name every time is inconvenient.

Note 1: While they are allowed in Unix file and folder names, most Unix shells require certain characters such as spaces, <, >, |, \, and sometimes :, (, ), &, ;, #, as well as wildcards such as ? and *, to be quoted or escaped:

five\ and\ six\ (example of escaping)
'five and six or "five and six (examples of quoting)

In Windows utilities the space and the period are not allowed as the final character of a filename. The period is allowed as the first character, but certain Windows applications, such as Windows Explorer, forbid creating or renaming such files (despite this convention being used in Unix-like systems to describe hidden files and directories). Among workarounds are using different explorer applications or saving a file with the desired filename from within an application .

Some file systems on a given operating system (especially file systems originally implemented on other operating systems), and particular applications on that operating system, may apply further restrictions and interpretations. See comparison of file systems for more details on restrictions.

In Unix-like systems, MS-DOS, and Windows, the filenames "." and ".." have special meanings (current and parent directory respectively).

In addition, in Windows and DOS utilities, some words might also be reserved and can not be used as filenames. For example, DOS device files:

CON, PRN, AUX, CLOCK$, NUL COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

Systems that have these restrictions cause incompatibilities with some other filesystems. For example, Windows will fail to handle, or raise error reports for, these legal UNIX filenames: aux.c, q"uote"s.txt, or NUL.txt.

NTFS filenames that are used internally include:

$Mft, $MftMirr, $LogFile, $Volume, $AttrDef, $Bitmap, $Boot, $BadClus, $Secure, $Upcase, $Extend, $Quota, $ObjId and $Reparse

Read more about this topic:  Filename

Famous quotes containing the words reserved, characters and/or words:

    Damn with faint praise, assent with civil leer,
    And, without sneering, teach the rest to sneer;
    Willing to wound, and yet afraid to strike,
    Just hint a fault, and hesitate dislike;
    Alike reserved to blame, or to commend,
    A timorous foe, and a suspicious friend;
    Dreading e’en fools, by flatterers besieged,
    And so obliging, that he ne’er obliged;
    Like Cato, give his little senate laws,
    And sit attentive to his own applause:
    Alexander Pope (1688–1744)

    Trial. A formal inquiry designed to prove and put upon record the blameless characters of judges, advocates and jurors.
    Ambrose Bierce (1842–1914)

    I have no words for my reality.
    Max Frisch (1911–1991)