MS-DOS [Working With Files] Part 5

Copying a Group of Files

To copy a particular group of files from one disk or directory to another, use the copy command with wildcards. For example, you could use the following command to copy all files with a .DBS extension from the current directory to a disk in drive B:
copy *.dbs b:
Suppose you have a number of files on a disk in drive A that you designated as temporary by giving them a .TMP extension. If you want to copy these files to a disk in drive B, you can use the asterisk wildcard:
copy a:*.tmp b:
When you use wildcards to specify the files to be copied, MS-DOS displays the file names as it copies the files.
A:JAN.TMP
A:MAR.TMP
A:FEB.TMP
 3 File(s) copied
You might have a group of files with filenames that differ only slightly. To copy them, you can use the question mark wildcard. For example, suppose you have four reports--JAN1RPT.DOC,JAN2RPT.DOC,JAN3RPT.DOC and JAN4RPT.DOC--on a disk in drive A. To copy the files to a disk in drive B, you could use the following command:
copy a:jan?rpt.doc b:
From drive A, MS-DOS copies the files that have seven-letter names (beginning with the letters JAN and ending with the letters RPT) and a .DOC extension.

If the disk you are copying to doesn't have enough space, MS-DOS stops copying and displays a message that tells you there is insufficient disk space and indicates how many files were copied. The last file displayed in the list before MS-DOS stops copying is not copied to the new disk.

For example, if the disk in drive B becomes full after three of the four .DOC files are copied, you would see a list similar to the following:

JAN1RPT.DOC
JAN2RPT.DOC
JAN3RPT.DOC
JAN4RPT.DOC

Insufficient disk space
3 File(s) copied

MS-DOS does not copy the JAN4RPT.DOC file to the disk in drive B.

Renaming a File as It Is Copied

To rename a file as it is copied, use the copy command and specify the new name, as in the following command:
copy prob.dbs b:noprob.dbs
If you want to assign  a new name to a file you are copying, specify the new filename as the destination file. (If you want to rename a file without making a copy, use the rename command discussed later in this chapter.)
For example, to copy the OUTGO.XLS file from a disk in drive A to a disk in drive B and rename the file EXPEND.XLS, use the following command:
copy a:outgo.xls b:expend.xls
You can rename groups of files by using wildcards. For example, if you want to copy .TMP files on a disk in drive A to a disk in drive B and give the files an .OLD extension, use the following command:
copy a:*.tmp b:*.old
You can copy a file to the same directory if you rename the file. If you don't rename the file when copying it to the same directory, MS-DOS displays the following message:
File cannot be copied onto itself
0 File(s) copied

Combining Text Files

To combine two or more unformatted text files into one file, use the copy command and include a plus sign (+) between the files you want to combine, as in the following command:

copy prob.txt + dob.txt probdob.txt
You can use the copy  command to combine two or more unformatted text files into one file. For example, the following command joins the files SCENE1.TXT and SCENE2.TXT on a disk in drive A into a new file named ACT1.TXT on a disk in drive B:
copy a:scene1.txt + a:scene2.txt b:act1.txt
MS-DOS joins the files in the order you type them. In this example, MS-DOS adds the SCENE2.TXT file to the end of the SCENE1.TXT file.

If you don't specify a destination file, MS-DOS combines all the files in the first file you specify. For example, to include the SCENE3.TXT file at the end of the ACT1.TXT file, you would use this command:

copy act1.txt + scene3.txt
You can also use wildcards to combine groups of files:
copy *.txt all.txt



Keyword: Learning MS-DOS | The Complete MS-DOS Commands | MS-DOS tutorial | MS-DOS Script

You may also like: