home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Big Blue Disk 5
/
bbd05.zip
/
CP.DOC
< prev
next >
Wrap
Text File
|
1987-01-07
|
6KB
|
154 lines
^C^1The CP Command
^C(Copy files)
^CWorks on Rainbow or IBM PC
^CVersion 2.2
The CP command is a replacement for the MS-DOS COPY command. It performs the
same basic functions, but has a number of additional features and enhance-
ments, which are discussed below. In addition, CP is able to copy files that
give COPY trouble, including zero-length files, filenames with non-standard
characters not normally allowed by DOS, etc.
^CSYNTAX
The syntax of CP is as follows:
cp [-diqv!] file,file,... target
Options are given as "switches." Each option has an associated letter, and
you should enter the options you wish to use as a series of one or more letters
preceded by a hyphen (-).
File specifications may contain a drive and/or a directory specification and
wildcard characters. The target specification is a file name or a drive
and/or directory name. Wildcard characters are not permitted in the target.
If more than one file is being copied (for example, when a list of source
file names is given, or wildcard characters are used), the target must be a
drive and/or directory name only. The file name of each file copied is used to
make the target file name.
If a source file specification contains a drive and/or directory, these are
passed along to the subsequent source file specifications until reassigned;
thus
cp \src\*.c,*.obj,\exe\*.* b:
is the same as
cp \src\*.c,\src\*.obj,\exe\*.* b:
and
cp b:bob,carol,\tmp\ted,alice \bed
is shorthand for
cp b:bob,b:carol,b:\tmp\ted,b:\tmp\alice \bed
If a target file exists, CP normally asks for verification before overwriting.
If there is not enough room on the target disk for the copy, the program pauses
while the user changes disks; the copy then proceeds.
^COPTIONS
Option: -d (delete after copy)
The source file is deleted without confirmation if the copy was successful.
Option: -i (input)
The list of files to copy is taken from the standard input device (normally
the keyboard, but redirectible through use of MS-DOS filter operators) rather
than the command line. Thus with -i the format of cp is
cp -i [-dqv!] target
This is useful when using cp as a filter, a powerful MS-DOS feature which
allows the output of one program to be channeled to become the input of
another. This is one of the places where you can use two Kramden Utilities in
combination. If you have the LS command (a powerful directory listing command
included in issue 4 of BIG BLUE DISK), you can use CP as a filter acting on
the output of LS like this:
ls -fm||cp -i a:
This line uses the MS-DOS filter operator "||" to send the output of the
command to the left of the bar (ls -fm) into the command to the right (cp -i
a:). The result of this particular command is to copy files in order from
smallest to largest. This insures that the most files will be copied to drive
a: before it fills.
There are lots of other ways you can use this combination of utilities. If
you wish to copy selected files in some particular order or according to some
particular criterion, you can devise an LS command sequence which generates a
list of the files you wish to copy, in the order you wish them copied, and
pipe it into CP as shown above.
Another use for this option is to copy a list of files given in another file.
For example, if the file "FILES.LST" contains a list of filenames, one on each
line, then the command
cp -i a: <files.lst
will cause the listed files to be copied to drive a:. This uses the MS-DOS
redirection operator "<" to send the contents of the file FILES.LST as the
input to CP. In general, "<" followed by a file or device name will cause
input to the command to be taken from the given file or device; conversely, ">"
followed by a file or device name sends output from the command to the file or
device.
Option: -q (quiet)
Supresses informational copy messages.
Option: -v (verify)
Causes user confirmation to be requested before copying. At each file prompt
the user answers either Y (do the copy), ! (do the copy and don't ask for
confirmation on future files), or N (don't copy this file). Any other answer
is the same as N.
Option: -! (hammer!)
Supresses the verification which is normally requested (even without -v) before
overwriting an existing file.
Options may be combined as in
cp -q! ...
^CHINTS AND TIPS
Since the "-" character is used to indicate command options, filenames which
begin with a hyphen must be preceded by a drive or path specification so they
are not mistaken for command switches. Thus, for instance, if you wish to
copy one of the directory delimiter files from BIG BLUE DISK, the direct
command "cp --------.000 b:" won't work; you should type it with a path, like
"cp .\--------.000 b:". (The path ".\" always refers to the current directory.)
When you copy with wildcards, like "cp *.* b:", there won't be any problem
copying files beginning with hyphens. Also, zero-length files such as the
directory delimiters will copy with no problem; the COPY command won't handle
them, but CP works fine.
If your disk has files containing spaces in their filename (DOS won't create
them, but BASIC can), there is no way to type the filename in a CP expression
(since the space is used as a separator); however, if you use a wildcard
expression like "*.*", these files will be copied, unlike the DOS COPY command,
which seems to choke on such files even within wildcards.
The CP! command is a shorthand for cp -!. Usage is
cp! [-diq] file,file,... target
Copyright (c) 1985,1986, by Bryan Higgins.
DISK FILE THIS PROGRAM USES: CP.EXE