dir *.doc returns incorrect files
When I type dir *.doc in a command prompt, it also returns docx (word 2007 etc.) files. This is even if I type dir "*.doc" How come? Is this "to be expected"? How can I get a directory listing which only lists Word 2003 and previous version "doc" files, and not the "docx" files? This also applies to other extensions: "dir *.xls" returns *.xlsx, *.xlsm, etc.
April 13th, 2010 5:38pm

Wow, you're absolutely right. I've just reproduced the same result myself. C:\TEMP\Test>DIR Volume in drive C is C - NoelC3 Volume Serial Number is 00ED-C11E Directory of C:\TEMP\Test 04/13/2010 11:35 AM <DIR> .04/13/2010 11:35 AM <DIR> ..07/15/1997 11:41 AM 28,672 V34Action.doc11/23/1998 01:17 PM 175,616 V34RRR.docx 2 File(s) 204,288 bytes 2 Dir(s) 1,610,634,571,776 bytes free C:\TEMP\Test>DIR *.doc Volume in drive C is C - NoelC3 Volume Serial Number is 00ED-C11E Directory of C:\TEMP\Test 07/15/1997 11:41 AM 28,672 V34Action.doc11/23/1998 01:17 PM 175,616 V34RRR.docx 2 File(s) 204,288 bytes 0 Dir(s) 1,610,634,571,776 bytes free There can be NO logical justification for this kind of syntax change, which makes results from a command that has worked one way for 20 years less deterministic. It must be a basic bug in wildcard handling! Thanks for the heads-up. Sometimes I use batch files and the DIR command to manipulate large blocks of files. I'll have to watch out for this ambiguity! -Noel
Free Windows Admin Tool Kit Click here and download it now
April 13th, 2010 6:39pm

Hi,We will report this behavior to proper department.Thank you for your feedbacks.Arthur Xie - MSFT
April 15th, 2010 10:53am

A follow-up:I have learned that this is a feature, not a bug, and it's tied to the generation of the 8.3 ("short") filenames feature in NTFS. The weird thing is that XP and Vista also did this, as it is by design, yet in all the years of using Windows I did not notice it. I just verified that.The command below in bold, entered into a CMD window, will disable the generation of 8.3 filenames AND change the DIR command so that it will match file extensions exactly. Note that if you do this some old 16 bit applications that you may be running and that require 8.3 filenames may stop working.fsutil.exe behavior set disable8dot3 1Microsoft's article on this is here: http://support.microsoft.com/kb/121007-Noel
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2010 4:08am

A follow-up:I have learned that this is a feature, not a bugwhat did you learn that makes this a feature and not a bug?
April 16th, 2010 5:06am

I don't think it is related to 16 bit applications only. There are 32 bit applications that don't play nice with long file names. (Even if it were: I am on Windows 7 x64, which does not have 16 bit support).But I think you are right that it is related to the short filename.I still wouldn't call it a feature, not even of the "feature, not bug" kind. If I did "dir /x *.doc" to get the 8.3 filenames, then I would expect it to work like this.To compare the matching: Cygwin's "ls" command will return only .doc files on "ls *.doc".Regards,Rasmus
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2010 9:09am

I agree with you about how it seems like it ought to work. What makes me think it's doing it by design is that it works exactly the same in XP, Vista, and Windows 7. Not only that, but I was told by someone who knows what they're talking about that it's working this way on purpose. I've yet to find hard documentation though.That XP and Vista do it too really surprised me, in that I've never noticed such an obvious glaring inaccuracy before. I guess I've not had that many different files with long extensions, even though long filenames have been around a very long time.I did do the reconfig on a virtual machine and in fact it does change the DIR command so that it works as expected. I may choose to disable 8.3 on my Windows 7 x64 main workstation as well... Have to mull it over for a while, as it does have some potentially serious side effects. However, that the file system might actually have a little better performance without it is attractive...-Noel
April 16th, 2010 2:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics