Long and short filenames
Windows 9x and Windows XP-based OSes both allow for long filenames on a FAT16 partition. These filenames are limited to 255 characters, but some applications like Windows 2000 Explorer (199 characters, including the period separator for the file extension), Windows XP Explorer (220 characters), and Windows 98 Explorer (235 characters) cannot display all of the characters of the filename. If you want to use names longer than Windows Explorer can display, you will have to use a different application.
On a FAT16 or FAT32 partition, you are still limited to the 8.3 naming convention. Windows 9x and Windows XP-based OSes get around this problem by cheating the file system. When you save a file, it is saved using one directory entry and a short 8.3-character filename. The short filename is created by using the first 6 characters of the filename followed by a tilde (~) and an incremental number.
If you are using a Windows XP-based OS, then after creating four files with the same 6 starting characters, the formula for creating short names is changed. The first two characters are used, followed by a randomly generated 4-digit hexadecimal number, followed by a tilde (~) and the number 1. Table below lists the names of six files and their short filenames that were created in the same directory on a Windows XP system. To get a listing of the short filenames, you can use dir /x or open the Properties window for each file, by right-clicking on the file and choosing Properties.Short Filenames in Windows XP
Long Filename Entry Short Filename Entry ShortFileTest1.txt SHORTF~1.TXT ShortFileTest2.txt SHORTF~2.TXT ShortFileTest3.txt SHORTF~3.TXT ShortFileTest4.txt SHORTF~4.TXT ShortFileTest5.txt SH0AF2~1.TXT ShortFileTest6.txt SHD0C6~1.TXT
If you are using Windows 9x, then the filenames continue to increment until you run out of directory entries on a disk or you hit the limit of 65,536 entries in any given directory. As the file names increment and move to ~10 or ~100, the number of characters at the start of the name decreases to five and then four.
Microsoft has stated in different documentation for Windows 9x that it will not allow more than 99 files to be created in a directory with the same initial characters for the short filename. So if there were several files that started with the words "My File for something.txt", then the last file that can be created in the directory has a short filename of myfil~99.txt. After performing tests with each version of Windows 9x, I can tell you that this stated information is wrong.
You have now seen how short filenames are generated, but the question about where the long filenames are stored still exists. The long filenames are stored in additional empty directory entries. The characters for the long filename are stored using 11 characters per additional directory entry. So a file with a name of My financial report for 2000.txt takes one directory entry of the short filename (possibly myfina~1.txt) and one additional entry for each of the 11 characters in the filename, or an additional three entries. That means that this one file would actually occupy four directory entries on your drive. These long filename directory entries have a non-standard attribute combination of Read-only, Hidden, System, and Volume Label. Although many files on your disk may have a combination of Read-only, Hidden, and System; Volume Label is usually used alone and only on one directory entry that stores the Volume Label for the disk. By using all four of these attributes, they are a nonstandard combination, and if MS-DOS systems see these entries, they ignore them rather than generating an error.
One of the problems with long filenames occurs when the long filename entries disappear. This can happen if you use MS-DOS-based disk utilities on your disk. Some of these utilities will tell you that you have a problem with your directory entries and offer to fix them. Fixing unfortunately means deleting all of the "invalid" entries, which means you lose all of your long filenames. This is not a good thing.
Microsoft makes conflicting claims about the compatibility of MS-DOS 6.x versions of scandisk.exe and defrag.exe. Some of their documentation states that MS-DOS 6.x utilities will not harm the long filename entries, while other documentation states that you should not use any MS-DOS-based file utilities. Used MS-DOS 6.x versions of defrag.exe on my disks, I have lost the long filename entries, which makes me think that these utilities are not compatible with the long filename entries.
For Windows 9x, Microsoft provides a utility called either lfnbk.exe or sulfnbk.exe, depending on your version. This program runs with one of two switches, either /b or /r. The first switch backs up all of your long filename entries into a file on the root of your drive (lfn.dat). It also strips the current names from your file system so that older utilities can be run. After using your utilities, you can then use lfnbk /r to restore your long filenames to their original state.
The brunt of many a virus hoax, sulfnbk.exe is a valid Windows application and not a virus, as has been often misreported on the Internet. There may come a time when you attempt to copy files to a destination that does not support long filenames. This used to happen with NetWare 3.x servers that had not enabled long filename support (OS/2 namespace). If this happens, you see a Rename File dialog box, for each file that has a long filename.
In this tutorial:
- Managing Files and Directories
- Identifying File-Naming Conventions
- Long and short filenames
- Creating file associations
- Understanding file extensions
- Compression utilities Extensions
- Graphic files Extensions
- Understanding File Attributes
- The basic attributes
- Windows 2000 and Windows XP extended attributes
- Setting basic attributes