KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q114816: Faster 8.3 Converted Long Filenames in NTFS

Article: Q114816
Product(s): Microsoft Windows NT
Version(s): WinNT:3.5,3.51,4.0
Operating System(s): 
Keyword(s): kbother
Last Modified: 08-AUG-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0 
- Microsoft Windows NT Server versions 3.5, 3.51, 4.0 
-------------------------------------------------------------------------------

SUMMARY
=======

Several Long Filename to 8.3 (MS-DOS compatible) name conversion performance
enhancements have been introduced in Windows NT Workstation and Windows NT
Server version 3.5(and later). These enhancements include a faster worst case
scenario algorithm, as well as improved context retention across enumeration
calls. Although these changes yield substantial improvements, you should
continue to avoid using numerous long, similar names.

MORE INFORMATION
================

In Windows NT version 3.1, worst-case file manipulation of extremely large
directories (500 to several thousand files) with similar long names was time
consuming. This was evident when receiving screen output from a DIR command or
reading a directory in File Manager.

In Windows NT 3.5(and later), NTFS has been enhanced to address these worst- case
scenarios as well as other general improvements in 8.3 enumeration.

Under Windows NT 3.1 NTFS, longfile names are converted to 8.3 names to support
DOS based clients. This conversion simply takes the first 6 characters of the
long name, and uses a "~n" suffix (where "n" is number) to keep the name unique
if needed. When the tenth filename is converted and the suffix exceeds 2
characters, only 5 characters of the name are used to accommodate the three
characters in the suffix and so on as needed. For example:

  MyTermPaper.doc   becomes  MYTERM~1.DOC
  MyTermPaper2.doc  becomes  MYTERM~2.DOC
  MyTermPaper3.doc  becomes  MYTERM~3.DOC
  MyTermPaper4.doc  becomes  MYTERM~4.DOC
  MyTermPaper5.doc  becomes  MYTERM~5.DOC
  MyTermPaper6.doc  becomes  MYTERM~6.DOC
  MyTermPaper7.doc  becomes  MYTERM~7.DOC
  MyTermPaper8.doc  becomes  MYTERM~8.DOC
  MyTermPaper9.doc  becomes  MYTERM~9.DOC
  MyTermPaper10.doc becomes  MYTER~10.DOC
  MyTermPaper11.doc becomes  MYTER~11.DOC

That algorithm had been changed in Windows NT 3.5(and later) for enhanced
performance. Since the occurrence of similar 8.3 names is generally minimal,
only the first four attempts at generating the 8.3 name work like they did in
Windows NT 3.1. The fifth attempt takes the first two characters of the long
name, then the next four characters are generated by a hashing function of the
entire name, and the last two characters are "~5". Only when the hashing of the
middle four characters no longer produces a unique name will the "~5" be
incremented to "~6" and so on. For example:

  MyTermPaper.doc   becomes  MYTERM~1.DOC
  MyTermPaper2.doc  becomes  MYTERM~2.DOC
  MyTermPaper3.doc  becomes  MYTERM~3.DOC
  MyTermPaper4.doc  becomes  MYTERM~4.DOC
  MyTermPaper5.doc  becomes  MY1E2E~5.DOC
  MyTermPaper6.doc  becomes  MY1EEE~5.DOC
  MyTermPaper7.doc  becomes  MY1EAE~5.DOC

Subsequent iterations are performed faster than under Windows NT 3.1.

NOTE: By avoiding using long names that are similar in the first 6 characters,
enumeration are even more efficient.

Additional query words: prodnt lfn long name

======================================================================
Keywords          : kbother 
Technology        : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT351search kbWinNT350search kbWinNT400search kbWinNTW350 kbWinNTW350search kbWinNTW351search kbWinNTW351 kbWinNTSsearch kbWinNTS400search kbWinNTS400 kbWinNTS351 kbWinNTS350 kbWinNTS351search kbWinNTS350search
Version           : WinNT:3.5,3.51,4.0

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.