Windows "Long File Name" Specification

This document consists of four parts. All are from Norton Utilities Help. Click to visit Symantec Corporation Website, the manufacturer of Norton Utilities.

Part One: About Long File Name

Before the introduction of Windows 95, the naming conventions for DOS and Windows files were restrictive. A filename had to follow the 8.3 format, that is, it could have a maximum of eight characters optionally followed by a file extension of up to three characters. A period separated the two parts.

In Windows, long filenames (including their extensions) can now contain up to 255 characters. As an extreme example, you could have a filename consisting of a period and a 254-character extension. (A long filename can contain more than one period. If it does, everything after the last period is considered the file extension.)

LFNs use the UNICODE character set, which requires two bytes for a single character. Short filenames use ASCII characters, which require one byte per character. 

To support this new capability, the directory entries for LFNs are implemented differently from the other directory entry types. For example, the LFN "THIS IS MY VERY LONG FILENAME.TXT" takes three entries.

LFN entries are 32 bytes long. The interpretation of the bytes distinguishes a short filename entry from an LFN entry. The most important difference between LFN and the other types of directory entries is that a single long filename can require multiple LFN entries, since each LFN entry has room for only 13 characters of the filename. Here is a description of the fields for LFN entries.

Byte Position

Field Name Description
0 Ordinal field Hexadecimal number indicating the order of LFN entries, since LFNs may require more than one directory entry. The first entry is numbered 01h, the second 02h, and so forth. The last entry has its seventh bit, the most significant bit, set to 1.
1-10 Filename chars 1-5 First five filename characters within this LFN entry. This field must have an entry.
11 File attributes Special properties of the entry, as explained in LFN directory entries.
12 Type Reserved for future use. Currently it always contains 0, which denotes an LFN entry.
13 Checksum Number verifying that the LFN directory entry is valid. The short filename for the file is the basis for this value.
14-25 Filename chars 6-11 Sixth through eleventh filename characters within this LFN entry. This field may be blank.
26-27 Cluster number No longer used, always 0. This field is to maintain backwards compatibility with older versions of DOS and other software.
28-31 Filename chars 12-13 The twelfth and thirteenth filename characters within this LFN entry. This field may be blank.

Part Two: About LFN Entries

A long filename has one or more LFN (long file name) directory entries followed by its short filename directory entry. An LFN must have an associated short filename because only the short filename stores the file's starting cluster.

The short filename is a unique filename based on characters contained in the LFN. For example, the LFN "THIS IS MY VERY LONG FILENAME.TXT" may have the short filename of THISIS~1.TXT. Windows generates this short filename. The tilde (~) and number ensure that no two long files have the same short filename. For example, if you create another file named "THIS IS MY LONG ESSAY.TXT", Windows assigns it a unique short filename of THISIS~2.TXT automatically.

Here is some other information about LFNs:

Text that makes up the LFN is in reverse order. The first LFN directory entry stores the last characters in the filename.

LFNs preserve the case used when the file was named. Short filenames do not.

Even though LFNs preserve case, searching for, moving, opening, or otherwise manipulating files having LFNs is case-insensitive. For example, if you want to open a file named "Budget for the First Quarter," the file will still be opened if you specify the filename as "budget for the first quarter" or use any combination of uppercase and lowercase letters.

An LFN becomes detached from its short filename if you move a file or rename the short filename using a pre-Windows 95 application or version of DOS. Use Norton Disk Doctor or Disk Editor to remove the LFN entries, or to reattach the LFN to the short filename.

Part Three: About short filenames

Before the release of Windows 95, all directory entries used what is now known as the short filename format. Three types of directory entries used this format:

Every directory entry is exactly 32 bytes, counted from 0 to 31. Here's a brief summary of the directory entry fields:

Byte Position Field Name Description
0-7 Filename Name given to the entry.
8-10 File extension File type identifier. Examples of common file extensions are .TXT, .DOC, and .EXE.
11 File attributes Special properties of the entry, as explained in a separate section.
12 NT attribute Reserved for use by Windows NT and Windows 2000.
13 Creation time (msec) This field is combined with the next one to provide a more precise time. The creation time measured by bytes 14 and 15 is accurate to the minute. Byte 13 indicates the number of milliseconds (thousandths of a second) following the last whole minute.
14-15 Creation time Time the entry was created. This field is accurate to the minute.
16-17 Creation date Date the file was created.
18-19 Last access date Date the file was last accessed, either for reading or for writing.
20-21 Extended attribute OS/2 field that points to other information about files, such as their icons and configuration information. Also called the EA handle, this field provides compatibility with OS/2.
22-23 Modified time Time the file was last modified.
24-25 Modified date Date the file was last modified.
26-27 Starting cluster First cluster in the FAT chain for a file or folder. When retrieving a file or folder, the operating system must first find this cluster so the FAT chain for the file can be traversed.
28-31 File size Number of bytes contained in the file.

Part Four: About file attributes

File attributes are a combination of several directory properties. When the operating system interprets these properties, it knows whether to treat an entry as a file, directory, volume label, or long file name (LFN).

There are a total of six file attributes. Each attribute has a different bit position within the byte allocated for this field. A directory entry has a particular attribute if that attribute's bit is 1.

X Unused bits (7th and 8th bits from the low end) These bits are always set to 0.
A Archive attribute (6th bit from the low end) When this bit is 1, the entry has not been archived (backed up).
D Directory attribute (5th bit) When this bit is 1, the entry is a folder.
V Volume label attribute When this bit is 1, the entry denotes a volume label or LFN. However, an LFN also has 1 bit for the S, H, and R attributes described below.
S System attribute When this bit is 1, the entry is a system file.
H Hidden attribute When this bit is 1, the entry is not included in directory listings, such as what appears in the file pane of the Windows Explorer or when the DIR command is issued from the command-line prompt. In both cases, however, you have the option of overriding the exclusion of hidden entries.
R Read-only attribute When this bit is 1, the entry can't be overwritten, deleted, or moved.

Notice there is no attribute to indicate that an entry is a file. Files without LFNs are entries where neither the directory nor volume label bit is set. Files with LFNs have LFN directory entries with their volume label, system, hidden, and read-only attributes set to 1. Windows uses this particular attribute combination to flag LFN directory entries because the combination would never be set by other software. This also provides compatibility with older applications. (The compatibility comes from the label attribute setting to 1, and in my opinion label attribute being one makes it sure that the entry is not a file - noted by Robbie Mosaic).

Return to Windows Basic Knowledge