MS-DOS [Working With Files] Part 3

Using Wildcards to Specify Groups of Files
Suppose a disk in Drive A contains variuos MS-DOS command (.COM) files. You could use the following dir command to view a list of all files that have a .COM extension:
dir a:*.com
Another way to view filenames on a disk is to use the dir command with the /w switch. The /w switch lists only the filenames and directory names and displays them across the width of the screen in several columns. You could view a list of files on a disk in drive A by using the following command:
dir a: /w
When you use the preceding command, MS-DOS displays a list similiar to the following:
Volume in drive A is Tambunan
Volume serial Number is xxxx - xxxx

Directory of A:\

AUTOEXEC.BAT    BACKUP.EXE    COMMAND.COM    CONFIG.SYS    COUNTRY.SYS
DISKCOPY.COM    DISPLAY.SYS   EGA.CPI        FDISK.EXE     FORMAT.COM
KEYB.COM        KEYBOARD.SYS  LCD.CPI        MODE.COM      REPLACE.EXE
RESTORE.EXE     SYS.COM
       17 File(s)       566862 bytes
                         77824 bytes free
You can use wildcards to view selected groups of filenames in this listing. For example, to view only filenames that have the .COM extension, type the following command:
dir a:*.com /w
MS-DOS lists the program files that have the .COM extension:
Volume in drive A is Tambunan
Volume serial Number is xxxx - xxxx

Directory of A:\

COMMAND.COM     DISKCOPY.COM    FORMAT.COM    KEYB.COM
MODE.COM        SYS.COM
        6 File(s)       197439 bytes
                         77824 bytes free
In addition to substituting for an entire name or extension, the asterisk wildcard can substitute for parts of a name or extension. For example, to view filenames that begin with the letter C on a disk in drive A, type the following command:
dir a:c*.* /w
MS-DOS lists the files that have names beginning with the letter C:
Volume in drive A is Tambunan
Volume serial Number is xxxx - xxxx

Directory of A:\

COMMAND.COM     CONFIG.SYS    COUNTRY.SYS
        3 File(s)        50459 bytes
                         77824 bytes free
If you use the asterisk wildcard to copy or delete a file, be careful not to specify a group of files instead of a single file. For example, if you have a file called MYTES.TXT and another named MYSALE.TXT, both files will be copied to drive A if you type the following command:
copy my*.txt a:
Unlike the asterisk wildcard, which substitutes for any or all characters in a name or extension, the question mark (?) wildcard substitutes for a single character. For example, to list the files that have names of up to three letters, type the following command:
dir a:???.* /w
MS-DOS lists files that have names of up to three letters, regardless of the name or extension:
Volume in drive A is Tambunan
Volume serial Number is xxxx - xxxx
Directory of A:\
SYS.COM         EGA.CPI    LCD.CPI       
        3 File(s)        71227 bytes
                         77824 bytes free

You may also like: