Category : File Managers
Archive   : KOPY12.ZIP
Filename : KOPY.DOC

 
Output of file : KOPY.DOC contained in archive : KOPY12.ZIP
Kopy, Version 1.2

KOPY is a small utility intended as a general replacement to the
DOS COPY command. Simply put, KOPY copies files matching a pattern to
a target directory. KOPY accepts either specific file names or
wildcards. If the source file pattern is not provided, "*.*" is
assumed; if the target directory is not provided, the current
directory is assumed (sounds like COPY so far). However, KOPY has a
few extra capabilities.

First, if the file already exists in the target directory, KOPY
alerts the operator. If the operator enters a 'y' or 'Y', KOPY goes
ahead and performs the copy. Anything else and KOPY skips to the next
file. Second, KOPY will optionally delete the source file after the
copy has been successfully performed. Third, KOPY will optionally
prompt before copying each file. Again a 'y' or a 'Y' okays the copy.
Anything else and KOPY skips to the next file without attempting the
copy.

The really big news, however, is that KOPY searches not only the
directory specified for files, but, optionally, all of its
subdirectories. For example, entering "KOPY \*.C B:" instructs KOPY
to search for all C source files found in the root and any of its
subdirectories on the current disk. The net effect of this is to copy
any .C file on the current disk, no matter what subdirectory it might
be in, to drive B.

Since B: is likely to be a floppy disk, the target disk might
fill. If the target disk does fill, KOPY prompts the user to insert a
new, blank disk. KOPY then continues from the point it left off with
the copy. This continues for as many floppy disks as it takes to
complete the copy operation.

KOPY does not recreate the directory structure it finds on the
target disk; that is, KOPY copies flat. If two files of the same name
are found in different directories, the operator must choose which one
to keep (the second will generate an "overwrite?" prompt).

Occasionally, the user simply wants to find files on the hard
disk and not actually copy them. KOPY can also be instructed to
dispense with the copy operation and simply list the file names it
finds. This option can be combined with the other options.

To be specific the switches defined for KOPY are:

/F - simply find (default is to also copy)

/D - delete the source file (if operator okays) (default is not
to delete the source)

/S - limit search to specified subdirectory (the default is to
search all subdirectories)

/V - verify okay before proceeding (default is to go ahead -
delete always requests permission)

/R - direct the copy to the standard output device (from which
it may be redirected via the ">" redirection symbol)

/U - update the creation date of the copy to the current date;
otherwise, retain the date of the original

/A - only find those files with the archive bit set (i.e.,
those files which have not been backed up -- note that
'kopy' does not clear the archive bit after copying as a
backup program might)

These switches can be used in any combination (they are
orthogonal). All reasonable formats are accepted, that is "/D /F" is
equivalent to "/D/F" which is equivalent to "/DF", and case is
ignored. For example,

KOPY *.C B: - copy all .C files in the current
directory and any of its
subdirectories to drive B

KOPY \USER\KOPY.C B:\USER - copy the file KOPY.C from directory
USER to directory USER on drive B

KOPY /S *.C B: - copy all of the .C files in the
current directory (but not its
subdirectories) to drive B

KOPY /V \*.C - copy all .C files in the root and
all of its subdirectories (i.e., the
entire hard disk) to the current
directory; ask before each one

KOPY /F/D \*.BAK - find and delete all .BAK files to
drive B; ask before each delete

KOPY /F/S \UTIL\*.COM - list all .COM files in the directory
UTIL

KOPY B:\ A: - copy the entire contents of disk B
to disk A irrespective of how many
directories B is divided into (a
blank filename is the same as *.*)

The only capability which KOPY is lacking with respect to DOS
COPY is the ability to copy to a file as well as a directory. For
example, entering "COPY FILE1 B:FILE2" will cause DOS COPY to copy the
file FILE1 to the file FILE2. KOPY would simply generate an error,
since it assumes that file2 is a subdirectory on disk B. This
"oversight" is intentional.

The problem with COPY's approach is that misspelled, but
otherwise syntactically correct, commands can have undesirable
results. For example, suppose the user wished to copy the file FILE1
to the subdirectory DIR2. In error, the user entered the command
"COPY FILE1 DIR1". Rather than inform the user of his error
(misspelling DIR2), COPY would create a file DIR1 in the current
directory without any indication of a problem. To avoid this problem,
KOPY insists that the target be a directory. The user should first
copy the file using KOPY and then rename it using the RENAME command.

There is one case where this ability to copy to a different file
name is very nice, however, and that is when copying to LPT1 (the
printer) or to CON (the console). The DOS command "COPY FILE1 LPT1"
is one way to print the file FILE1. To accommodate this very useful
practice, KOPY implements the /R switch which causes the copy to be
directed to CON instead of a directory (like TYPE). From this point,
output can be redirected to the printer. For example:

KOPY /D/R \*.LIS >LPT1 - copies all of the listing files
(.LIS) on the current disk to the
printer and then deletes them

(Notice how output can be redirected to any file desired so that
KOPY can, in fact, copy to a file. By using a slightly different
syntax to do so, however, KOPY is assured that the user did not merely
misspell the directory name.)

KOPY and its switches effectively replaces several DOS commands
and common public domain utilities. For example:


KOPY /SFD pattern is the same as ERQ pattern
(erase with question)

KOPY /F \pattern is the same as WHEREIS pattern
or KOPY /FV \pattern (search hard disk for file)

KOPY /FD \pattern is the same as SCLEAN pattern
(clean the disk of a pattern)

KOPY /R pattern is the same as TYPE

KOPY is better than COPY

KOPY /R pattern >lpt1 is the same as COPY pattern lpt1

KOPY /FS pattern is the same as DIR pattern


Notice that all of the above switches are toggles. That is,
specifying a switch twice has the same effect as not specifying it at
all. This is to allow .BAT files to be created to change the default
switch values for KOPY. For example, suppose that the user would like
KOPY to default to "current subdirectory only" search mode instead of
"subdirectories also". One might invent a file, KPY.BAT, with the
following contents:

KOPY /S %1 %2 %3

Using "KPY" now specifies a default "current directory only"
search; however, when it is desired to include the subdirectories, the
user can still specify "KPY /S". This expands to "KOPY /S /S", which
is the same as not specifying "/S" at all.


KOPY was developed by Stephen R. Davis with Borland's Turbo C
Version 1.0 as part of the book "Turbo C: The Art of Advanced Program
Design, Optimization and Debugging" from M&T books. It is donated
into the public domain for the use and enjoyment of the PC community.
KOPY may be used and distributed freely and without charge. There are
only two caveats: 1) modified versions of KOPY should not be uploaded
into the public domain (I don't want to be responsible for errors
introduced) and 2) the banner providing order information for ordering
"Turbo C", in the event the user is interested in learning more, must
not be removed. Bugs and questions may be reported to 1-214-454-2426.

Stephen R. Davis
October, 1987



Note #1: As no consensus could be reached as to which was
better, the source code to KOPY has been purposely designed to allow
the default of "subdirectories also vs. current directory only" to be
easily changed. Compiling KOPY.C results in a program which defaults
to including subdirectories (in which case "/S" can be read "Single
directory only"). This is the way the help screen is written.
Defining the label SWITCH before compiling KOPY.C reverses the sense
of the "/S" switch (in which case, read "/S" as "plus
Subdirectories"). This also adds a line to the help screen warning of
the switch.

Note #2: Under DOS 2.x, certain data path enhancers (most
notably FILEPATH) can get KOPY confused as to whether a file exists or
not. For example, suppose the user entered "KOPY FILE1 B:". Further,
suppose that FILE1 did not exist on B: but did exist somewhere in the
data path. KOPY might find FILE1 in the path, conclude that it
already exists and generate the "overwrite?" message. KOPY uses the
Create New system call available under DOS 3.x to avoid this problem.





  3 Responses to “Category : File Managers
Archive   : KOPY12.ZIP
Filename : KOPY.DOC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/