Wildcards

 
Wildcards are symbols that enable us to perform an MS-DOS operation on more than one file at a time. A file specification that contains wildcards can refer to more than one file because it gives MS-DOS a pattern to match.
 
MS-DOS searches for any file whose filename or extension matches the pattern. There are two wildcard characters:
 
? A question mark in a filename or extension means that up to a maximum of ONE character/letter/number can occupy that position.
* An asterisk in a filename or extension means that any number of characters/letters/numbers, (up to maximum of EIGHT before the dot, and up to a maximum of THREE after the dot) can occupy that position.
 
NOTE:-
There can be LESS than the maximum number of characters/letters/numbers.
 
For example suppose you had a directory containing the following files,
 
A.DOC
AA.DOC
AAA.DOC
B.DOC
A.TXT
B.TXT
 
The following command and file patterns match some or all the above files:-
DIR *.DOC Is the equivalent to DIR ????????.DOC and matches the first four files (those with the DOC extension)
 
DIR *.* Is the equivalent to DIR ????????.??? and matches ALL files. Use *.* with care e.g. DEL *.* deletes ALL files in the current directory, regardless of extension!!
 
DIR ?.DOC Matches A.DOC and B.DOC
 
DIR ?.* Matches A.DOC, B.DOC, A.TXT and B.TXT
 
DIR A?.DOC Matches A.DOC and AA.DOC
 
DIR A*.DOC Matches A.DOC, AA.DOC and AAA.DOC
 
Scroll to Top