Saturday, 5 January 2013

Copying Files

The COPY command is a very powerful command within DOS. With it you can create
duplicates of individual files, join several files into one, and even use your computer like a simple
typewriter by "copying" from the device named CON: to the device named PRN (inefficient, but
OK for short notes).
Copying one file to another (copies from filename1 to filename2):
COPYd1:FILENAME1.ext d2:filename2.ext/v
/v option verifies the copy as it takes place. This adds confidence at the price of slower operation.
There are other options not shown here. Wildcards are allowed.
For example,
C:\>COPY ADDRS.LST B: Copies the single file ADDRS.LST from C: to B:.
C:\>COPY *.* B:/VCopies all files on C: to the disk in B: and verifies the information is it is being
written.
C:\>COPY ADDRS.LST Yields an error message. Can't copy a file to itself.
C:\>COPY B:*.*Copies all files from drive B: to drive C:. (If a destination is not specified, the
default drive and directory is used.)
Copy can also be used to concatenate (join) several files by using the following form:
COPYd1:FILENAME1.ext+d2:FILENAME2.ext+... d0:filename0.ext/v
The options are the same as the previous version of the copy command.
All specified file names (#1, #2, etc.) will be copied and joined into filename0. If no filename0 is
specified, the first source file named will be used.
Wildcards are dangerous with this command. 

Example:
Contents of FILE1:This is file number one
Contents of FILE2:This is file number two
C:\>COPY FILE1+FILE2 FILE3
Contents of FILE3: This is file number one This is file number two
The COPY command can be used to create text files by copying from device CON: to a file.
The procedure is outlined in the text of the example below.
C:\>COPY CON: TEXT FILE
This is the text to go into the text file being created. Each line is typed to the screen and it is
being saved into a buffer for later transfer to the file TEXT FILE. Each line may be corrected as it is
typed, but cannot be changed after it is terminated by the carriage return. Also, if you happen to
type beyond column 80 on the screen, you cannot correct anything on the line above. Each line
must be terminated by a carriage return (the enter key). You  signal you are finished by typing a
Control-Z, the symbol for end-of-file, followed by Return. ^Z
1 File(s) copied

No comments:

Post a Comment