Dictionary

What Is The File Name?

The File Name is the name a file has in its folder, such as tmp.txt. The file system keeps this name outside the file, and you can change the name.

file-name

A file name is the name that identifies a file in its folder. A file name has a base name and an optional extension, separated by a period. In tmp.txt, the base name is tmp and the extension is txt.

In a metadata report, the File Name field shows this name. You can choose the name and change it later, because the name is not part of the file's content.

Where the value comes from

The file system keeps the file name in the folder, not inside the file. The metadata reader ExifTool therefore calls File Name a pseudo tag, like the file size.

Some formats store a name inside the file as well:

  • A ZIP archive stores the name of every file it contains, with an optional relative path.
  • A gzip file can store the original name of the file it compressed, without any folder names.
  • An ID3v2 tag, as found in MP3 files, can store an original filename in the TOFN frame.

A download can also get a suggested name from outside the file. A web server can send this name in the Content-Disposition header, as in filename=example.html. The program that saves the download should treat this name as advice only.

What the value looks like

File Name shows the full name with its extension, but without the folder path. ExifTool keeps the folder in a separate Directory field. For many formats, the extension matches the file type.

Windows treats OSCAR, Oscar, and oscar as the same name. A POSIX file system can treat them as 3 different names. On Windows, one name is commonly limited to 255 characters, and a classic full path to 260 characters.

Which characters a file name cannot use

On Windows, a file name must follow these rules:

  • The name must not contain the characters :, ", /, |, ?, *, the backslash, the less-than sign, or the greater-than sign.
  • The name must not contain a character with an integer value from 0 to 31.
  • The name must not be a reserved device name, such as CON, PRN, AUX, NUL, COM1, or LPT1, with or without an extension. Microsoft's naming rules treat NUL.txt the same as NUL.
  • The name must not end with a space or a period. The file system may accept such a name, but the Windows shell does not.

The POSIX standard for portable operating systems is less strict. A POSIX file name can contain any byte except the slash and the null byte.

For a name that moves safely between POSIX systems, POSIX defines a portable character set. The set has the letters A to Z and a to z, the digits 0 to 9, the period, the underscore, and the hyphen. POSIX advises against a hyphen as the first character, because it can cause problems on the command line.

Why it matters

A file name must be unique in its folder. The extension is part of the name. So 2 files with the same base name and different extensions can share a folder.

Renaming a file does not change its content, and a new extension does not change the format. ExifTool can write a new File Name without changing the file itself.

Normally, ExifTool reads the file header to find the file type. A special fast setting skips the header and takes the file type from the extension.

A title stored inside the file is separate from the file name. A PDF can store a Title, and an ID3v2 tag stores a song title in the TIT2 frame. Renaming the file changes neither title.