Strange Windows DIR command behavior

Posted by user1167442 on Super User See other posts from Super User or by user1167442
Published on 2012-06-19T18:25:29Z Indexed on 2012/06/20 3:18 UTC
Read the original article Hit count: 438

Filed under:
|
|
|

I discovered this quite by accident while looking for a file with a number in the name. When I type:

dir *number*

(where number represents any number from 0 to 9 and with no spaces between the asterisks and the number)

at the cmd.exe command prompt, it returns various files do not appear in any to fit the search criteria. What's weird, is that depending on the directory, some numbers will work and not others. An example is, in a directory associated with a website, I type the following:

dir *4*

and what is returned is:

Directory of C:\Ampps\www\includes\pages 

04/30/2012  03:55 PM               153 inventory_list_retrieve.php
06/18/2012  11:17 AM             6,756 ix.html
06/19/2012  01:47 PM           257,501 jquery.1.7.1.js
               3 File(s)        264,410 bytes
               0 Dir(s)  362,280,906,752 bytes free

That just doesn't make any sense to me. Any clue?

The question is posed on stackOverflow because the DIR command is often combined with FOR in batch programs. The strange DIR behavior would seem to make batch programs potentially unreliable if they use the DIR command.

© Super User or respective owner

Related posts about Windows

Related posts about command-line