Using Wildcards to Match Files
Tumpal Tambunan
You can use wildcards to match one file or group of files with another. For example, to change all files with a .BAT extension to a .BAK extension on a disk in drive A, you could use the following rename (ren) command:Viewing Text Files
ren a:*.bat *.bakThe first and second wildcards are used in different ways. MS-DOS uses the first to find all files that have a .BAT extension; it uses the second to create a name that matches the original name of each .BAT file.
To copy all files on a disk in drive A that have names beginning with F and editing with .BAT extensions to a disk in drive B, keeping their original names but changing their extensions to .BAK, you could use the following copy command:
copy a:f*.bat b:*.bak
To view the contents of a text file, use the type command. For example, to view the contents of the LIST.TXT file on a disk in drive A, you would use the following command:Copying Files
type a:list.txtIf the file you want to view is large, you could use a pipe (|) followed by the more command, as follows:
type a:list.txt | moreBy including the more command, you can view the file one screen at a time.
Use the type command to view the contents of unformatted text files and batch programs. (You can look at the contents of other kinds of files, too. However, only the text is readable). When you use the type command, MS-DOS displays the entire file on your screen. You cannot change the text or view only a portion of the file.
For example, you can use the type command to see the contents of your AUTOEXEC.BAT file. AUTOEXEC.BAT is a batch program that carries out certain commands when you start your system. If you have a hard disk, the AUTOEXEC.BAT file should be in your root directory on drive C. If you have a floppy disk system, you will find it on the disk you use to start your system.
If you have a floppy disk system, you can view the AUTOEXEC.BAT file by putting the disk you use to start your system in drive A and typing the following command:type a:autoexec.batIf you have a hard disk, and it is drive C, type this command to view your AUTOEXEC.BAT file:
type c:\autoexec.batYou must precede more with a pipe (|). By using this command, you can view your file one screen at a time.
TIP If you don't use the more command when you use type, you can temporarily stop the display of a file by pressing CTRL + S or the PAUSE key while the file is scrolling. To start viewing more of the file, press any key (except PAUSE)
To stop viewing a file, press CTRL + C or CTRL + BREAK, which cancels the type command.
The copy command is your primary tool for organizing and making copies of files. With the copy command you can do the following:Copying a Single File
- Copy the file from one directory or disk to another.
- Copy a group of files by using wildcards.
- Rename a file as you copy it.
- Combine two or more files into one file.
CAUTION When you use the copy command, avoid inadvertently destroying a file by copying over it. For example, if you copy a file called SCORES.DAT to a directory that already has a file with the name, MS-DOS replaces the existing file with the new copy.
To copy a file to another disk or directory, use the copy command. For example, you would use the following command to copy the PROB.DBS file from a disk in drive A to a disk in drive B:
copy a:prob.dbs b:When using the copy command, you type the location and filename of the file you want to copy from, followed by the location and filename of the file you want to copy to. The first file is called the source file and the second file is called the destination file.
For example, to copy the OUTGO.XLS file from a disk in drive A to a disk in drive B, you would type the following command:copy a:outgo.xls b:outgo.xlsMS-DOS makes a copy of the OUTGO.XLS file on the disk in drive A and puts it on a disk in drive B in a file having the same filename. If you want the source and destination files to have the same filename, you omit the destination filename. For example, you could use the following command to produce the same result achieved by using the previous command:copy a:outgo.xls b:After you use the copy command, MS-DOS indicates how many files were copied:
1 File(s) copiedIf MS-DOS cannot find the file you want to copy, it displays a "File Not Found" message. Check to see that you typed the filename correctly and that the file is in the directory you specified.
|
You may also like: