Filename
From Wikipedia, the free encyclopedia
A filename is a special kind of string used to uniquely identify a file stored on the file system of a computer. Depending on the operating system, such a name may also identify a directory. Different operating systems impose different restrictions regarding length and allowed characters on filenames. A filename includes one or more of these components:
- protocol (or scheme) — access method (e.g., http, ftp, file etc.)
- host (or network-ID) — host name, IP address, domain name, or LAN network name (e.g., wikipedia.org, 207.142.131.206, \\MYCOMPUTER, SYS:, etc.)
- device (or node) — port, socket, drive, root mountpoint, disc, volume (e.g., C:, /, SYSLIB, etc.)
- directory (or path) — directory tree (e.g., /usr/bin, \TEMP, [USR.LIB.SRC], etc.)
- file — base name of the file
- type (format or extension) — indicates the content type of the file (e.g., .txt, .exe, .dir, etc.)
- version — revision number of the file
In order to refer to a file on a remote computer (aka: host, server) the remote computer must be known. The remote computer name or address might part of the file name, or it might be specified at the time a file system is "mounted", in which case it won't necessarily be part of the file name.
In some systems, if a filename does not contain a path part, the file is assumed to be in the current working directory.
Many operating systems, including MS-DOS, Microsoft Windows, and VMS systems, allow a filename extension that consists of one or more characters following the last period in the filename, thus dividing the filename into two parts: the basename (the primary filename) and the extension (usually indicating the file type associated with a certain file format). On these systems the extension is considered part of the filename, and on systems which allow (for example) an eight character basename followed by a three character extension, a filename with an extension of "" or " " (nothing, or three spaces) will still be 11 characters long (since the "." is supplied by, but not considered as part of the name by, the OS). On Unix-like systems, files will often have an extension (for example prog.c, denoting the C-language source code of a program called "prog"); but since the extension is not considered a separate part of the filename, a file on a Unix system which allows 14-character filenames, and with a filename which uses "." as an "extension separator" or "delimiter", could possibly have a filename such as a.longxtension
Within a single directory, filenames must be unique. However, two files in different directories may have the same name. On Unix, however, upper-case and lower-case are considered different, so that files MyName and myname would be valid names for different files in the directory; historically, names with upper-case characters in them have come before those with all-lower-case names in them in directory (folder) listings; many Unix software vendors use this scheme to make important files, such as INSTALL or README, appear in listings before relatively less important files or directories (like lib).
Unix-like systems allow a file to have more than one name; in traditional Unix-style file systems, the names are hard links to the file's inode or equivalent. Hard links are different from Windows shortcuts, Mac OS aliases, or symbolic links.
The address (unique resource identifier - URI)
Contents |
[edit] Reserved characters and words
Many operating systems prohibit control characters from appearing in file names. Unix-like systems are an exception, as the only control character forbidden in file names is the null character, as that's the end-of-string indicator in C. Trivially, Unix also excludes the path separator / from appearing in filenames.
Some operating systems prohibit some particular characters from appearing in file names:
Character | Name | Reason |
---|---|---|
/ | slash | used as a path name component separator in Unix-like and Amiga systems. Not allowed in MS-DOS and Windows. |
\ | backslash | used as a path name component separator in MS-DOS and Windows, and as the escape character in Unix systems, see Note 1 |
? | question mark | used as a wildcard in Unix, Windows and AmigaOS; marks a single character. |
% | percent sign | used as a wildcard in RT-11; marks a single character. |
* | asterisk | used as a wildcard in Unix, MS-DOS, RT-11, VMS and Windows. Marks any sequence of characters (Unix) or any sequence of characters preceded or followed by a . (thus "*.*" in Windows means "all files". |
: | 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 "\\".) |
| | vertical bar | designates software pipelining in Windows, see Note 1 |
" | quotation mark | 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 | allowed but the last occurrence will be interpreted to be the extension separator in VMS, MS-DOS and Windows. In other OS's, usually considered as part of the filename, and more than one full stop may be allowed. |
Note 1: Some applications on Unix-like systems might allow certain characters but require them to be quoted or escaped; for example, the shell requires spaces, <, >, |, \ and some other characters such as ; to be quoted:
five\ and\ six\<seven (example of escaping)
'five and six<seven' or "five and six<seven" (examples of quoting)
In Windows 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 from an application with the desired name.[1]
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 imposed by particular file systems.
In Unix-like systems, MS-DOS, and Windows, the file names "." and ".." have special meanings (current and parent directory respectively).
In addition, in Windows and DOS, some words might also be reserved and can not be used as filenames.[1] For example, DOS Device file:
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.
Operating 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.
Block quote
[edit] Comparison of file name limitations
System | Alphabetic Case Sensitivity | Allowed Character Set | Reserved Characters | Reserved Words | Maximum Length | Comments |
---|---|---|---|---|---|---|
MS-DOS FAT | case-insensitive case-destruction | A-Z,0-9,-,_ | all except allowed | 8 + 3 | ||
Commodore 64 | case-sensitive case-preservation | any | " | 16 | Flat filesystem with no subdirs. Space and shift-space are different chars. | |
Win95 VFAT | case-insensitive | any | |\?*<":>+[]/ control characters | 255 | ||
WinXP NTFS | optional | any | |\?*<":>/ control characters | aux, con, prn | 255 | |
WinXP HPFS | case-insensitive case-preservation | any | |\?*<":>/ | 254 | ||
Mac OS HFS | case-insensitive case-preservation | any | : | 255, though Finder limited to 31 | ||
Mac OS HFS+ | case-insensitive case-preservation | any | : on disk, in classic Mac OS, and at the Carbon layer in Mac OS X; / at the Unix layer in Mac OS X | 255 | Mac OS 8.1 - Mac OS X | |
most UNIX file systems | case-sensitive case-preservation | any | / | 255 | a leading . means ls and file managers will not by default show the file | |
AmigaOS | case-insensitive case-preservation | any | :/" | 107 | dos.library | |
Amiga OFS | case-insensitive case-preservation | any | :/" | 30 | Original File System 1985 | |
Amiga FFS | case-insensitive case-preservation | any | :/" | 30 | Fast File System 1988 | |
Amiga PFS | case-insensitive case-preservation | any | :/" | 255 | Professional File System 1993 | |
Amiga SFS | case-insensitive case-preservation | any | :/" | 32000 | Smart File System 1998 | |
Amiga FFS2 | case-insensitive case-preservation | any | :/" | 107 | Fast File System 2 2002 | |
BeOS BFS | case-sensitive | UTF-8 | / | 255 | ||
DEC PDP-11 RT-11 | case-insensitive | RADIX-50 | 6 + 3 | a full "file specification" includes device, filename and extension (file type) in the format:
dev:filnam.ext |
||
DEC VAX VMS | case-insensitive | A-Z, 0-9, _ | 32 per component; earlier 9 per component; latterly, 255 for a filename and 32 for an extension. | a full "file specification" includes nodename, diskname, directory/ies, filename, extension and version in the format: OURNODE::MYDISK:[THISDIR.THATDIR]FILENAME.EXTENSION;2 Directories can only go 8 levels deep. |
Also: consider that ISO 9660 defines a maximum directory depth / level of 8, assuming a maximum length of 255, this leads to an overall maximum url length of 2040.
[edit] See also
[edit] References
- ^ a b Naming a file msdn.microsoft.com (MSDN), filename restrictions on Windows
[edit] External link
- Large list of filename extensions: File-extensions.org
- Filename Strategy for Managing Image Assets: ControlledVocabulary.com
- Recommendations for Limitations on Image Filenaming: ControlledVocabulary.com