DOS uses wildcard characters to represent specific letters or numbers as a variable. This is useful when you are looking for a series of files or you want to perform an action on many files at the same time.
The asterisk (*) wildcard represents any number of characters that you are looking for.
The question mark (?) wildcard represents a single character or number. You can use multiple ? wildcards in a single query. This wildcard is not as commonly used as *.
Create the directory structure and files shown in the previous exercise. Refer to 'Creating and Deleting Directories' for help on creating the DOS directory structure and to 'Editing Text Documents' for help on creating the text files.
Access the C:\TEST directory.
Type DIR *.TXT and press Enter.
You should see FILE1.TXT, FILE2.TXT, FILE3.TXT, FILE4.TXT, PAPER1.TXT, and PAPER2.TXT.
Type DIR *.DOC and press Enter.
You should see FILE5.DOC and FILE10.DOC.
Type DIR FILE?.* and press Enter.
Notice that FILE10.DOC does not show up, because the ? wildcard indicates only a single placeholder.
Type DIR P*.TXT and press Enter.
You should see PAPER1.TXT and PAPER2.TXT.
Type REN F*.DOC F*.TXT and press Enter.
Type DIR *.DOC and press Enter to see whether any DOC files remain.
Type DEL P*.* and press Enter.
Type DIR P*.* and press Enter to see whether any of the files beginning with P remain.
As an example of how to use these wildcards, assume you have this directory structure:
Note | As you can see, wildcards make DOS management a lot easier and more efficient than managing files on an individual basis. |
|
|