How MS-DOS 6.22 Handles File Wildcards

This article explains how MS-DOS 6.22 processes wildcard characters—specifically the asterisk (*) and question mark (?)—during command-line file operations. In MS-DOS 6.22, wildcards are constrained by the legacy 8.3 filename architecture and internal parsing mechanisms, causing them to behave differently than modern regular expressions or Unix-style shell globbing. Understanding these mechanics reveals why common commands like DIR, COPY, REN, and DEL yield specific, sometimes unexpected, search and matching results.

The 8.3 Filename Architecture and Wildcard Expansion

MS-DOS 6.22 treats every filename as an 11-character array split into two distinct fields: an 8-character primary name and a 3-character extension. If a filename or extension contains fewer characters than the maximum allowed, DOS pads the remaining positions with space characters ( ).

When DOS processes a command containing wildcards, it internally converts the pattern into an 11-byte search mask before comparing it against directory entries. Wildcards operate within their specific field boundaries (name or extension) and never cross the dividing dot.

The Question Mark (?)

The question mark is a single-character wildcard, but its behavior depends on its position within the 8.3 structure:

  • Fixed Matching: When placed within the body of a filename, a ? matches any single valid character at that exact position. For example, B?LL.TXT matches BILL.TXT, BALL.TXT, and BELL.TXT.
  • Trailing Matches: If one or more question marks extend past the length of an actual filename into the padded space area, MS-DOS treats the question mark as matching either a character or a blank space. Consequently, FILE???.TXT matches FILE.TXT, FILE1.TXT, FILE12.TXT, and FILE123.TXT.

The Asterisk (*)

In MS-DOS 6.22, the asterisk functions as a greedy macro rather than an arbitrary substring matcher. When DOS encounters an *, it fills the remainder of the current field (either the 8-character name field or the 3-character extension field) with ? characters.

Because DOS expands the asterisk immediately to the end of the field, any characters placed after an asterisk within the same field are completely ignored:

  • Trailing Characters Ignored: Entering A*B.TXT does not find files that start with "A" and end with "B". Instead, DOS converts A* to A followed by seven question marks (A???????), effectively treating the command as A*.TXT.
  • The Global Matcher (*.*): Entering *.* expands to eleven question marks (????????.???). This matches every file in the directory, including files that do not possess an extension.
  • Matching Files Without Extensions: Entering *. (an asterisk followed by a dot, with no extension characters) instructs DOS to search for ???????? in the name field and three literal blank spaces in the extension field, matching only files that lack an extension.

Command-Specific Behavior: The Rename (REN) Command

While commands like DIR, COPY, and DEL use wildcards purely as filters to select source files, the REN (rename) command allows wildcards in both the source and the destination arguments.

When used in a destination argument, a wildcard tells DOS to preserve the character from the original filename at that relative position:

  • REN *.TXT *.BAK matches every file with a .TXT extension and substitutes .BAK into the extension field while leaving the 8-character base name unchanged.
  • REN ????.DOC ????.BAK keeps the first four characters of matching files intact while altering the extension.

If the destination pattern contains fewer characters than the source file, DOS does not truncate the file unless explicitly masked. The character-by-character mapping copies the corresponding character from the original filename whenever a ? or * appears in the target argument.