<< Previous    1...   18  19  20  [21]  22    Next >>

 

 

Wildcards

Wildcards enable you to manipulate a group of files using a single DOS command.  The object here, just like using wildcards in poker, is to specify wildcards in a filename in such a way as to match other files on disk.

For example, if you've named all the chapters in your Great America Novel with the DOC extension, you can treat all of them as a group using a wildcard.  If all your special project files start with PROJ, you can do things to those files en masse - even if the rest of the files are named something completely different.

There are two wildcards DOS uses, the question mark (?) and the asterisk(*).  They are covered in the following two sections.

 

Using the ? wildcard

The ? wildcard is used to match any single letter in a filename.  It can be used by itself or in multiples of however many characters you want to match.  For example:

The wildcard filenames TH?? Matches all four-letter filenames starting with TH, including THIS and THAT.

The wildcard filename CHAP?? Matches all files starting with CHAP and having one or two more letters in their name.  This includes CHAP00 through CHAP99 and any other combination of characters in those two positions. 

You can also use the ? wildcard in the second part of a filename:

The wildcard filename BOOK.D?? matches all filenames starting with BOOK and having D as the first letter of their extension.

You can even mix and match the ? wildcard:

The wildcard filename JULY????.WK? matches all files starting with JULY that have WK as the fist two letters of their extension.

All of those wildcard combinations can be used with DOS's file exploitation commands: DIR, DEL, COPY, REN and so on.

 

Using the *wildcard

The * wildcard is more powerful than the single-character? Wildcard.  The asterisk is used to match groups of one or more characters in a filename.  Here's an example: 

The wildcard filename *.DOC matches all files that have DOC as their second part.  The first part of the filename can have any number of characters in it, *.DOC matches them all. 

The wildcard filename PROJECT.* matches all files with PROJECT as their first

Part, with any second part - even if they don't have any second part.

But beware!  The * wildcard is rather lame when it comes to being used in the middle of a filename.  For example:

The wildcard filename B*ING part of the name because it comes after the wildcard.  I know.  It's dumb.  But that's the way DOS is. 

If you want to match all filenames that start with B, use this wildcard:

B*

This matches all files, whether or not they have a second part.  True, you could use B*.*, but DOS matches the same files, so why bother with the extra dot-star?

The wildcard * (star-dot) matches only filenames without an extension.  This is the only time under DOS that a command could end in a period.  Here's an example:

C> DIR *.

 In this example, the DIR command shows only files without any extension (typically only the subdirectories).

 

<< Previous    1...   18  19  20  [21]  22    Next >>