2.5
File Management Commands:
COPY
Type: Internal
Syntax: COPY [/Y|-Y]
[/A][/B]
[d:][path]filename [/A][/B]
[d:][path][filename] [/V]
or
COPY [/Y|-Y] [/A][/B]
[d:][path]filename+[d:][path]filename[...]
[d:][path][filename] [/V]
Purpose:
Copies or appends files. Files can be copied with the same name or with a new
name.
Discussion
COPY is
usually used to copy one or more files from one location to another. However, COPY
can also be used to create new files. By copying from the keyboard console
(COPY CON:) to the screen, files can be created and then saved to disk.
The first
filename you enter is referred to as the source file. The second filename you
enter is referred to as the target file. If errors are encountered during the
copying process, the COPY program will display error messages using these
names.
Unlike the
BACKUP command, copied files are stored in the same format they are found in.
The copied files can be used just as you would use the original (whether the
copied file is a data file or a program).
COPY can also
be used to transfer data between any of the system devices. Files may also be
combined during the copy process.
NOTE:
Files can be
copied to the same directory only if they are copied with a new name. If you
copy a file to a different directory without specifying a new name, the file
will be copied with the same name. If you attempt to copy a file to the same
directory without providing a new name, DOS will cancel the copy and display
the message
File cannot be copied onto itself
Options
/Y -
Causes COPY to replace existing files without providing a confirmation prompt.
By default, if you specify an existing file as the destination file, COPY will
provide a confirmation prompt. (In previous versions of DOS, existing files
were simply overwritten.)
/-Y - Displays a
confirmation prompt before copying over existing files.
/A -
Used to copy ASCII files. Applies to the filename preceding it and to all
following filenames. Files will be copied until an end-of-file mark is
encountered in the file being copied. If an end-of-file mark is encountered in
the file, the rest of the file is not copied. DOS will append an end-of-file
mark at the end of the copied file.
/B -
Used to copy binary files. Applies to the filename preceding it and to all
following filenames. Copied files will be read by size (according to the number
of bytes indicated in the file’s directory listing). An end-of-file mark is not
placed at the end of the copied file.
/V -
Checks after the copy to assure that a file was copied correctly. If the copy
cannot be verified, the program will display an error message. Using this
option will result in a slower copying process.
Examples
The first
filename you enter is the source file; the second file is the target file. To
copy the file CHAP.DOC from the current directory to drive D (with the same
name), enter copy chap.doc d:
To copy the file CHAP.DOC to the
current directory with the new name, CHAP1, enter
copy chap.doc chap1
To copy and combine (concatenate)
the files CHAP1.DOC and CHAP2.DOC to a new file, CHAP3, enter copy
chap1.doc+chap2.doc d:chap3
You can also
combine files by using wildcard characters (? and *). To copy all files with a
.TXT filename extension on drive C to a new file TEXTFILES on drive D, enter copy
c:*.txt d:textfiles
Other, more
complicated, combinations are also possible while copying. For example, to
combine all files with a .TXT filename extension with all files that have the
same filename and a .DOC extension, copying the newly combined file to a new
file on drive B with an .ADD extension, enter
copy *.txt+*.doc b:*.add
In this case,
the file CHAP.TXT will be combined with the file CHAP.DOC resulting in a
combined file with the filename
CHAP.ADD.
|