Filename

From Free net encyclopedia

(Redirected from File name)

A filename is a special kind of string used to uniquely identify a file stored on a computer. Different operating systems impose different restrictions regarding length and allowed characters on filenames. The address (unique resource identifier - URI) of a file includes at least 4 different parts:

  1. computer id (IP address, domain name or LAN computer name eg: wikipedia.org, 207.142.131.206 or \\MYCOMPUTER )
  2. device(drive, root mountpoint, disc, volume, eg: C:, /)
  3. path (position in directory tree : everything between the first and last path separator)
  4. filename

In order to refer to a file on a remote computer (aka: host, server) its network id must be provided. If an URI does not contain a path part, the file is assumed to be in the current working directory.

Many systems, including DOS and UNIX, allow a filename extension that consists of one or more characters following the last period thus dividing the filename into two parts

  • the basename (aka: proper filename, primary filename)
  • and the extension (usually indicating the file type associated with a certain file format or mime type)

Within a single directory, filenames must be unique. However, two files in different directories may have the same name. Some operating systems, such as UNIX and the Macintosh operating system, allow a file to have more than one name, called an alias or hard link (see also: inode).

Note: These are different from windows shortcuts, symbolic links, soft links or hyperlinks.

Reserved Words

On most operating systems a filename may not contain any of the following characters because they have special meanings in the filesystem:

  • any control character (0-31)
  • / SLASH (used as a path separator; symbol for the root on UNIX)
  • | PIPE
  • \ BACKSLASH (used as a path separator)
  •  ? QUESTIONMARK (used as a wildcard in Windows)
  • " DOUBLE-QUOTATIONMARK (used to mark beginning and end of filenames containing spaces)
  • * STAR (used as a wildcard in Windows)
  •  : COLON (used to determine the mount point / drive on windows)
  • < LESS THAN
  • > GREATER THAN
  • . (allowed but the last occurrence will be interpreted to be the extension separator)

In Windows the space and dot are not allowed as the final character of a filename.

In addition, some words may also be reserved and can not be used as filenames.

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.
You must avoid using those reserved names as a filename suffix or file name body, eg: aux.c, file.aux or NUL.txt

The comparison of the filename in different operating systems

Although possible on most newer operating systems, for portability reasons it is not recommended to use non-western characters or spaces when naming files. Also some operating systems (UNIX) are case sensitive meaning - myFile is not the same as myfile - while others are not (Windows).

The maximum length of a filename including the extension on different systems is:

System CaseSensitive AllowedCharset ReservedChars ReservedWords MaxLength Comments
MS DOS no A-Z,0-9,-,_ all except allowed 12 ISO-9660, CD Filesystem
Win95 no A-Z, a-z,0-9,-,_ \?*<":>+[] control characters 255
WinXP NTFS optional Any \?*<":> control characters aux, con, prn 2048 maximum length of entire url in IE
WinXP HPFS no Any \?*<":> 254
MAC OS9 (Classic) case-preserving Any  : 255, though Finder limited to 31
MAC OSX case-preserving Any  : 255
UNIX yes any / 256 a leading . makes it a system file

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.

External links

pl:Ścieżka dostępu zh:檔案名稱