# File Extension

Key: `representation.file.extension`

File name extension or suffix (txt, pdf, docx, jpg, etc.). May include or exclude leading dot.

Page: <https://meridian.online/docs/projects/finetype/types/representation/file/extension>

Samples: `txt`, `.pdf`, `docx`, `jpg`, `xlsx`

## Background

### Origin

The basic concept of extensions to indicate the type of file was first introduced in MIT's CTSS in 1961.[[1]](https://en.wikipedia.org/wiki/Filename_extension) CTSS stored two separate names for each file, a file name and a class name, corresponding to today's name and extension.[[1]](https://en.wikipedia.org/wiki/Filename_extension)

In DOS and 16-bit Windows, file names have a maximum of 8 characters, a period, and an extension of up to three letters.[[1]](https://en.wikipedia.org/wiki/Filename_extension) The FAT file system stores a file name as an 8-character name and a three-character extension, and the period character is not stored.[[1]](https://en.wikipedia.org/wiki/Filename_extension) The need to condense a file's type into three characters frequently led to abbreviated extensions, such as .TXT for plain text and .MUS for music.[[1]](https://en.wikipedia.org/wiki/Filename_extension)

The classic Mac OS did without filename-based extensions entirely, using a distinct file type code to identify the file format instead.[[1]](https://en.wikipedia.org/wiki/Filename_extension) macOS uses filename suffixes as a consequence of being derived from the UNIX-like NeXTSTEP operating system.[[1]](https://en.wikipedia.org/wiki/Filename_extension)

### Use

The exact rule for which part of a file name is its extension belongs to the file system, but usually the extension is the substring after the last dot, so txt is the extension of readme.txt.[[1]](https://en.wikipedia.org/wiki/Filename_extension) Python's pathlib returns the suffix of my/library.tar.gz as .gz, with the leading dot included.[[2]](https://docs.python.org/3/library/pathlib.html) Python's pathlib returns an empty string as the suffix of a path with no extension, such as my/library.[[2]](https://docs.python.org/3/library/pathlib.html) More than one extension usually represents nested transformations, as in files.tar.gz, a tar archive compressed with gzip.[[1]](https://en.wikipedia.org/wiki/Filename_extension) A column of extensions is easiest to compare once the leading dot is stripped and the case folded, so that .PDF, pdf and .pdf count as one value. (Meridian's view) Before you strip anything, check whether the column was cut at the last dot or the first: a source that wrote gz for an archive has lost the tar that tells you what is inside. (Meridian's view)

Some extensions have conflicting uses, such as .rpm, used for both RPM Package Manager packages and RealPlayer Media files.[[1]](https://en.wikipedia.org/wiki/Filename_extension) File extensions alone are not a reliable indicator of a file's type, as the extension can be changed without changing the file's contents.[[1]](https://en.wikipedia.org/wiki/Filename_extension) Treat an extension column as what the file claims to be, not what it is, and reach for a media type or the file's own bytes when the difference matters. (Meridian's view)

## Sources

1. [Filename extension](https://en.wikipedia.org/wiki/Filename_extension) — secondary source
2. [pathlib — Object-oriented filesystem paths](https://docs.python.org/3/library/pathlib.html) — documentation
