WinXP dir command: 3 and 4 char extensions are the same?

I'm trying to recursively search a directory tree to find all of the .asp files using the following command:

dir *.asp /s

For some reason, this returns not only the asp files, but also the aspx files.

How can I force it to ignore the aspx files?


Solution 1:

dir /x

For compatibility reasons, Windows generates a 8.3 name for every long file name created, and wildcard matching code (FindFirstFile()) checks both the original and shortened names. Use dir /x to see what short names are assigned to each file.

The "extension" part of a 8.3 name is always created by simply truncating the last extension to at most 3 characters: .aspx to .ASP


When using the NTFS filesystem, 8.3 name creation can be disabled system-wide using:

fsutil behavior set disable8dot3

However, this won't affect existing names. You will have to rename each file and then rename it back to its original name.


See also: Directory search in Windows Command Prompt shows incorrect output!