Category : Modula II Source Code
Archive   : FLXCPY10.ZIP

Output of file : FLEXCOPY.DOC contained in archive : FLXCPY10.ZIP
FLEXCOPY --- Flexible Copy Program for MS-DOS.

Version 1.0
Released November, 1989, Bit Bucket Software
David P. Lemire


FLEXCOPY is a general purpose file copying utility for
MS-DOS. It offers an extended copy syntax that allows the
user to copy or move files from multiple source file
specifications to a single destination with one command.
FLEXCOPY can copy or moves files and provides a number of
switch options to control the copying process. FLEXCOPY is
invoked by typing:

FLEXCOPY [switches] SourceSpec [SourceSpec] [DestinationSpec]

If used with a single source specification, FlexCopy works
just like the DOS copy command, except that it cannot
concatenate files, and can't copy to DOS devices
(e.g., LPT1). However, FlexCopy's real use is to specify a
number of source file specs, and copy them all at once. For
example, if your computer has a RAM disk, and you wish to
copy a number of utilities to it at boot time, you might
include a line such as the following in your autoexec.bat:

flexcopy setpath.bat \utils\ \utils\pk*.* d:

This would copy all of the specified files from the boot
drive (presumably C:) to the RAM disk, here assumed to be
D:. As shown, each source specification can be a single
file or a wild card, and can include a path specification as
well. Also, the use of . and .. to specify the current and
parent directories are also supported.

File specifications will be fully qualified (drive and
complete path inserted before the filename), and reported to
the console using the following notations:

"FileFrom => FileTo" for copies, and
"FileFrom -> FileTo" for moves.

This file processing report appears before the copy or move
action is performed. The user can terminate the copy
operation after the current file by pressing the ESCAPE key.
This will cause FLEXCOPY to finish copying or moving the
current file and exit to DOS. (This feature is similar to
the use of the ESCAPE key in the DOS XCOPY utility. A side
effect is that it prevents the use of type-ahead while
FLEXCOPY is running.)

FlexCopy accepts a number of switches. Switches are
preceeded with a / character. Switches can be separate (/x
/m) or concatenated (/xm). The allowed switches are
descibed below, in the section on switches. Typing only
FLEXCOPY with no arguments will print a usage message (the
line above with the list of switches). Using the /H or /?
options will produce a help screen explaining the effects of
the switches.

There are two caveats that apply to using FlexCopy.
First, it's very easy to assume that the current directory
is always the default destination, as with the DOS COPY
command; however, this doesn't work when more than one
source spec is given. The rule is:

If there is a single file specification on the
command line, the current directory is the
target (destination) directory. If MORE THAN
ONE file specification is on the command line,
the LAST file spec is the target directory.

Some examples to make this clear; for all of these, assume
the current drive and directory are C:\UTILS:

FLEXCOPY a:\*.com -- will copy all .COM files from A:\
to C:\UTILS. This is exactly
like the DOS syntax.

FLEXCOPY a:\*.com b:\*.exe
-- will copy all .COM files from A:\
to .EXE files on B:\; for example
A:\BROWSE.COM would be copied to
B:\BROWSE.EXE -- this may not be
what was intended.

FLEXCOPY a:\*.com b:\*.exe c:
-- will copy all .COM files from A:\
and all .EXE files from B:\ to
C:\UTILS (the current directory),
which may have been what you
intended in the second example.

The second caveat concerns the length of the command line.
The MS-DOS command line is limited to 127 chars (about 1-1/2
lines on an 80 column screen). When specifying multiple
files, it's easy to get carried away, and type in a command
line longer than 127 chars. In that case, the command line
gets truncated, and the last thing on it gets used as a
destination. For example, if the current directory is
D:\FLEXCOPY, and the 127th character of the command line is
the 'f' before the caret:

flexcopy flexcopy.mod entrexit.def ... copyfile.mod d:

The resulting output from flexcopy would look something like

d:\flexcopy\flexcopy.mod => d:\flexcopy\copyf
d:\flexcopy\entrexit.def => d:\flexcopy\copyf

This result is due to the truncation of the command line.
In general, if your command line is less than 1-1/2 lines on
the screen, you should be OK.


The following paragraphs describe the available
switches and their affects. Certain switches can be placed
in an environment variable named FCSW to change the
default mode of operation. If conflicting switches are
used, the last switch processed determines the operation of
the program; also, command line switches override both
program defaults and environment variable options. For
example, if the command line contained:


FLEXCOPY would freshen the files on the target drive (the
/F, overriding the /U), and provide no output (the /Q).
Only the first letter of the option should be used (e.g., /P
but not /Prompt); switch processing is not case sensitive.

NOTES: A plus (+) by a switch indicates the default program
operating mode. These switches may appear in the
environment variable, but will not change program
operation as they repeat the default operating

Asterisks (*) indicate other switches that may
appear in the environment variable.

File copy control switches:

/M -- Move files (instead of copying). Reports will be
in the form "FileFrom -> FileTo," to distinguish
them from normal copies. Moving uses the DOS
renaming function, unless the target is a
different drive, and thus very fast.

/F -- Freshen, copy files that match the souce spec-
ification and exist at both the source and the
destination, but have newer versions (i.e., a
later date) at the source.

/U -- Update, copy all files that match the source spec
from source to destination, unless a source file
is not newer than the matching file at destina-

Program control switches:

/H or
/? -- Help, show help screen summarizing the use of the
FLEXCOPY switches.

* /P -- Prompt, query user for each file whether that file
should be copied or moved.

+ /N -- No Prompt, process files normally.

* /Q -- Quiet, no output to console, unless there is an

+ /V -- Verbose, report all actions to the console.

* /X -- Suppress copyright banner. If no files are
copied, due to the use of /Update or /Freshen,
this switch also suppresses the "0 file(s) copied"

The freshen switch allows the use of a *.* source spec
to copy altered files, but not new or unchanged files, to the
target. The update switch will copy all files that match the
source specification, but will save time by not copying
unchanged files. These switches only have an effect when
files are being copied; they are ignored when used with the
/Move option. The /Prompt option also overrides the /Freshen
and /Update switches. The escape key function also isn't
available if the /Prompt option has been selected.

Switches intermingled with files are processed, however,
all switches are processed before copying starts, so it is
not possible to "group" switches with files. For example


would copy all .COM and .EXE files to \tempdir and produce no

You can set an environment variable, FCSW (FlexCopy
SWitch), to alter the default parameters. For example, SET
FCSW=P will cause FLEXCOPY to always prompt the user on
a file-by-file basis if the file shown should be copied
(moved). FLEXCOPY can still be made to copy all files
without prompting by using a /N on the command line. The
command line switch overrides both the environment setting
and the built-in default. All switches except M, F, U, H or
? are legal in the environment variable. FLEXCOPY will abort

with an error message if any of these switches appear in the
environment variable. An error message will also be printed
if an unrecognized switch appears either in the environment
variable or on the command line.


FLEXCOPY sets the DOS error level upon exit to reflect the
results of its operation. The error level values returned by
the program are as follows:

0 -- Completely successful operation.
1 -- Help or usage message printed.
3 -- Attempted to copy or move a file to itself.
2 -- Attempted to copy or move several files to one
4 -- Tried to copy or move to a DOS device.
5 -- Some failure to handle a directory associated with
a command line argument.
6 -- User terminated program before completion (used
the ESCAPE key).
7 -- Not all files copied due to target disk full.
255 -- Undefined failure.


FLEXCOPY attempts to prevent the user from moving or
copying multiple files to a single target file. If an
operation such as FLEXCOPY /M *.C FILENAME.BAK is attempted,
the first file matching *.C will be moved to FILENAME.BAK and
the operation aborted with the second file. The "single
target file" protection operates by determining if the
destination is a file, or it is a wildcard or a directory.
It is possible to write a destination wildcard such that two
different source file names will result in the same
destination file name. FLEXCOPY will not detect this
condition, and will copy the second file over the first file.

FLEXCOPY deletes incomplete files in the target directory
if an error occurs while writing the file. Such an error
usually signifies the target disk doesn't have enough space
for the file. However, FLEXCOPY will continue operation, and
attempt to copy the remaining specified files. Thus if the
source list includes one large and several small files,
FLEXCOPY may copy the small files but not the largest one.
The exact files that get copied under these circumstances
depend on the order the files were specified. The DOS error
level after program termination in this case will be seven

The use of DOS devices (e.g., CON:, LPT1:) is not
supported by FLEXCOPY. If you need, for example, to create a
file by copying from the console you must use the 4DOS COPY
command, rather than FLEXCOPY. File concatenation (e.g.,
file1+file2) also is not supported.

FLEXCOPY can handle up to 150 files per source file
specification. This limit is due to the way directories are
handled internally. If you are copying a directory with more
than 150 files, it will be necessary to use multiple wild
cards, rather than a *.* to specify the files.

FLEXCOPY does not copy files that have the hidden
attribute set, so it will work correctly with the exception
utilities such as PC-Magazine's NO.COM.


/Move Move files.

/Freshen Copy only newer versions of existing

/Update Copy all specified files unless an
existing target file is newer.

/Help or /? Show help information.

/Prompt Query user for each file.

/NoPrompt Process files normally.

/Quiet No output to console, unless error

/Verbose Report all actions to the console.

/X Suppress copyright banner, 0 file


FlexCopy is written in Modula-2, and compiled with the
FTL Modula-2 compiler, version 1.17.

The command line syntax of FlexCopy is based on that of
the copy command in the 4DOS command processor. This program
is a modified version of a program originally written for use
with 4DOS. 4DOS is a replacement for COMMAND.COM that offers
a great number of enhancements and extensions. 4DOS is a
shareware program, and worth checking out if you use a PC a
lot and find the limitations of the DOS command processor

FlexCopy also incorporates ideas from XCOPY (the escape
key function), the PKWare family of file compression
utilities (the /Freshen and /Update capabilities), and the
excellent FGREP text search program (the /X to suppress the
version notice).

This program is released into the public domain. I
would be interested in ideas about the program or
enhancements developed by other people. Please send ideas,
comments, bug reports, and new source code with feature
enhancements to:

David P. Lemire
9318 Farewell Road
Columbia, MD 21045


  3 Responses to “Category : Modula II Source Code
Archive   : FLXCPY10.ZIP

  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: