Using the DOS Wildcards

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 *.

start sidebar
Test It Out: Using DOS Wildcards
  1. 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.

  2. Access the C:\TEST directory.

  3. Type DIR *.TXT and press Enter.

    You should see FILE1.TXT, FILE2.TXT, FILE3.TXT, FILE4.TXT, PAPER1.TXT, and PAPER2.TXT.

  4. Type DIR *.DOC and press Enter.

    You should see FILE5.DOC and FILE10.DOC.

  5. Type DIR FILE?.* and press Enter.

    Notice that FILE10.DOC does not show up, because the ? wildcard indicates only a single placeholder.

  6. Type DIR P*.TXT and press Enter.

    You should see PAPER1.TXT and PAPER2.TXT.

  7. Type REN F*.DOC F*.TXT and press Enter.

    Type DIR *.DOC and press Enter to see whether any DOC files remain.

  8. Type DEL P*.* and press Enter.

    Type DIR P*.* and press Enter to see whether any of the files beginning with P remain.

end sidebar

As an example of how to use these wildcards, assume you have this directory structure:

click to expand

Note 

As you can see, wildcards make DOS management a lot easier and more efficient than managing files on an individual basis.




MCSA. MCSE 2003 JumpStart. Computer and Network Basics
MCSA/MCSE 2003 JumpStart
ISBN: 078214277X
EAN: 2147483647
Year: 2003
Pages: 203
Authors: Lisa Donald

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net