A Tale of Two File Names
The article explains the legacy 8.3 filename system in Windows, a holdover from DOS and early Windows that shortens long filenames using tildes and checksums to maintain compatibility. It details how filenames are truncated and transformed, including the use of an undocumented checksum function when naming conflicts occur. The author reverse-engineers the Windows API using debugging tools to uncover how the system generates these short filenames.
- ▪8.3 filenames are a legacy feature from DOS and early Windows, limiting filenames to 8 characters and extensions to 3.
- ▪Special characters are replaced, filenames are upper-cased, and tildes with numbers (e.g., ~1) are used to resolve naming conflicts.
- ▪When ~5 would be reached, a hexadecimal checksum replaces the number, such as in SOBC84~1.ASP.
- ▪The Windows API function GetShortPathName retrieves precomputed short filenames rather than generating them on the fly.
- ▪The checksum algorithm used for 8.3 filenames is undocumented and appears to be a custom Microsoft implementation.
Opening excerpt (first ~120 words) tap to expand
Users of DOS or older versions of Windows will have invariably stumbled upon a quirk of Windows’ handling of file names at some point. File names which are longer than 8 characters, have an extension other than 3 character long, or aren’t upper-case and alphanumeric, are (in some situations) truncated to an ugly shorter version which contains a tilde (~) in it somewhere. For example, 5+6 June Report.doc will be turned into 5_6JUN~1.DOC. This is relic of the limitations brought about by older versions of FAT used in DOS and older versions of pre-NT Windows. In case you aren’t aware of how 8.3 file names work, here’s a quick run-down. All periods other than the one separating the filename from the extension are dropped - a.testing.file.bat turns into atestingfile.bat.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Tomgalvin.