Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:57:11+00:00 2026-06-06T01:57:11+00:00

I discovered this quite by accident while looking for a file with a number

  • 0

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.

Edit: (additional note). Though much time has passed, I discovered another quirk with this that almost cost me a lot of work. I wanted to delete all .htm files in a particular directory tree. I realized just before doing it that *.htm matches .html files as well. Also, *.man matches .manifest, and there are probably others. Deleting all .html files in that particular directory would have been upsetting to say the least.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:57:12+00:00Added an answer on June 6, 2026 at 1:57 am

    Wild cards at the command prompt are matched against both the long file name and the short “8.3” name if one is present. This can produce surprises.

    To see the short names, use the /X option to the DIR command.

    Note that this behavior is not in any way specific to the DIR command, and can lead to other (often unpleasant) surprises when a wild card matches more than expected on any command, such as DEL.

    Unlike in *nix shells, replacement of a file pattern with the list of matching names is implemented within each command and not implemented by the shell itself. This can mean that different commands could implement different wild card pattern rules, but in practice this is quite rare as Windows provides API calls to search a directory for files that match a pattern and most programs use those calls in the obvious way. For programs written in C or C++ using the “usual” tools, that expansion is provided “for free” by the C runtime library, using the Windows API.

    The Windows API in question is FindFirstFile() and its close relatives FindFirstFileEx(), FindNextFile(), and FindClose().

    Oddly, although the documentation for FindFirstFile() describes its lpFileName parameter as “directory or path, and the file name, which can include wildcard characters, for example, an asterisk (*) or a question mark (?)” it never actually defines what the * and ? characters mean.

    The exact meaning of the file pattern has history in the CP/M operating system dating from the early 1970s that strongly influenced (some might say “was directly copied” in place of “influenced” here) the design of MSDOS. This has resulted in a number of “interesting” artifacts and behaviors. Some of this at the DOS end of the spectrum is described at this blog post from 2007 where Raymond describes exactly how file patters were implemented in DOS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just discovered, quite by accident, that this seems to work: Public Interface Ix
I've seen a plugin for Vim called AutoClose (discovered from this post) which automatically
Quite by accident today, I discovered that in IE6, IE7 and IE8 it is
I just discovered, quite by accident, that a WCF service hosted in a Windows
I just discovered this operator and I was wondering if it is safe to
I just discovered this component and started working with it. I understand that the
Possible Duplicate: Python or Ruby Interpreter on iOS I just discovered this apps pypad
I am working with zend just recently. I discovered this ViewScript decorator for form
This problem was discovered when I tried to run the Android emulator in Eclipse.
I just discovered a bug where the code looked something like this: char *foo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.