File Management Commands
DOS Wildcards
Wildcards
Wildcards are characters that can be used to stand-in for unknown characters in file names. In card games, a wildcard is a card that can match up with any other cards.
In DOS, wildcard characters can match up with any character that is allowable in a file name.
There are two wildcards in DOS:
* = matches up with any combination of allowable characters
? = matches up with any single allowable character
Of course, since these two characters are used for wildcards, they are not allowable in filenames themselves. A filename like myfile?.txt would not be allowed. If you tried to create a file with this name you would get an error message "Bad file name." But wildcards are very useful in any DOS command which uses a filename as an argument.
The apostrophe character, *, can stand in for any number of characters. examples
c:\>del *.doc
This command would delete every file with the doc extension from the root directory of
C: . So files like myfile.doc, testfile.doc, and 123.doc would all be deleted.
C:\>copy ab*.txt a:
This command would copy every file that began with ab, and had an extension of txt, to the floppy drive
A: . So files like abstract.txt, abalone.txt , and abba.txt would all be copied.
C:\temp\>del *.*
This is the fastest way to clean out a directory. This command will delete every file in the directory C:\temp\. The first apostrophe covers every filename, and the second one covers every extension.
C:\>del ?.doc
This command would only delete files that had a single character filename and a doc extension from the root directory. So a file like a.doc or 1.doc is history, but a file like io.doc is perfectly safe, since it has two characters.
C:\>copy ab?.txt a:
were ab, and with a txt extension, to the floppy drive A: . So files like abz.txt and ab2.txt would be copied.
You can combine these wildcards in any command as well.
C:\temp\>del *ab?.do?
This command would be very selective. It would look in the temp directory for files that had anywhere from 1 to 5 beginning characters, followed by ab followed by one character, and which had an extension of do followed by any one character.
It would then delete any such files as matched. Examples of matching files would be itab3.dox, mearabt.doq, and 123abc.doc. But the file allabon.doc would not be deleted because it does not match. It has two characters following the letters ab in the filename, and the command specified one character in that position.
Lets refer next tutorial