Master Copy

MCP.EXE

The Better XCOPY

Version 1.50
February 5, 1995
(C) 1993-1995 Michael Paul Johnson.
All rights reserved. No warranty.

Table of Contents

INTRODUCTION    
RUNNING MCP     
MOVING FILES    
ZERO LENGTH FILES       
PROMPTS 
ERROR MESSAGES  
ERRORLEVEL      
NAME TRIVIA     
LIMITATIONS     
LEGAL NOTICES   
HOW TO CONTACT THE AUTHOR       
VERSION HISTORY 
INVOICE 

INTRODUCTION

MCP (Master Copy) is kind of like XCOPY, but it 
normally only overwrites older files and it can move files. It 
was written primarily for use in keeping directory structures 
shared by different people (or by the same person on different 
computers) in synchronization with each other. It is also a 
quick way to implement disk mirroring style backups. It now has 
lots of options, possibly including one or two you would like to 
use.

RUNNING MCP

MCP is a DOS command line utility with a syntax that is an 
extension of the XCOPY that comes with DOS:

MCP source [destination] [switches]

Switches can be:

/A = copy only files with Archive bit set (leave source archive 
bit set).

/B = ask permission Before overwriting each existing destination 
file.

/C = Copy & overwrite all files except those with identical 
date, time & size.

/D = copy files with Date the same or later than Date given 
/D:mm-dd-yyyy /D:dd.mm.yyyy /Dmm/dd/yy /Ddd.mm.yy or /Ddays.

/D- = copy files with Date earlier than Date given /D-mm-dd-yyy 
/D-dd.mm.yyy /D-mm/dd/yy /D-dd.mm.yy or /D-days.

/F = Force overwrite of system, hidden, and read only files.

/H = Copy system and Hidden files as well.

/I = Inhibit actual copy. Tests what MCP would do.

/J = Just copy files that already exist in destination 
directory.

/L = List lots of loud verbose output (for troubleshooting).

/M = copy only files with archive bit set (Modify source archive 
bit).

/N = No overwrite.

/O = Overwrite destination files.

/P = Prompt before copy.

/Q = Quiet (report only errors).

/R = Rename or move files.

/S = /E = recurse through Subdirectories (& create Empty ones).

/T = Stop Twirling "propeller" (useful for redirection).

/U = Update (overwrite only older files -- the default mode).

/V = This switch doesn't cause an error message, but it doesn't 
do anything. It is included so that batch files written for 
XCOPY can use MCP with the same switches. (/V turns verify on in 
XCOPY). To turn on verify, use the DOS command VERIFY ON before 
using MCP.

/W = Wait for keystroke before starting copy

/? = Show help screen.

On the command line, source is a file name or directory name, 
which may optionally include drive and path. It may also include 
DOS wild cards ? and *. If the source is a drive or directory, 
the file specification *.* is assumed.

The destination is a file name or directory. If no destination 
is specified, the current directory is assumed. If there are 
wild card characters in the destination file name, they will be 
filled in with the corresponding characters in the source file 
name. If it is not obvious if the destination is a file or 
directory, you may be asked which you meant. To ensure that the 
destination is interpreted as a directory instead of a file, end 
the directory name in "\" or ensure that the destination 
directory already exists. If the destination directory does not 
exist, it will be created.

Switches all start with "/" (not "-", since - is a valid file 
name character in DOS), and may be before, between, and/or after 
the source and destination. Switches may be combined. In case of 
a conflict between switches, the one that is farthest to the 
right on the command line takes precedence. For brevity, most 
command line switches may be run together after a single "/". 
Switches are not case sensitive.

/A (Archive) and /M (Modify archive) both specify that only 
files that have the DOS directory archive bit set (indicating 
that they have been changed since they were last backed up) 
should be copied. /A does not alter the archive bit on the 
source file. /M clears the archive bit of the source file to 
indicate that it has been backed up. The archive bit of the 
destination file is always set when using MCP. These options can 
be used for backing up data when the largest file you want to 
back up will fit on your destination media. If the largest file 
you want to back up is bigger, a regular backup program is more 
appropriate than MCP.

 However, for some small but important files, backing up with a 
copy command like MCP makes more sense, because the file itself 
is not altered, making restoration possible even without the 
original backup program.

For example, 

MCP /A C:\WORK\DOC\*.* A:

copies all files in C:\WORK\DOC to the floppy disk in A: that 
have not been marked as backed up.

/B (ask Before overwrite) causes MCP to stop and ask if you want 
to copy each file for which the destination file already 
exists.

/C (Copy & overwrite all but identical date, time & size) will 
cause all destination files with the same name but different 
(older or newer) date & time or different size (smaller or 
larger) to be overwritten.

/D (Date) is always followed by a date, a number of days old, or 
a dash then a date or number of days old. There is no space in 
between the /D and the date. If the first character after the 
date is a "-", then the copy is for dates before the date 
indicated. If the first character after the /D is a ":" or a 
number, then the copy is for dates on or after the date 
indicated. The colon following the D is optional. The order of 
the date is month day year if you use "/" or "-" to separate the 
numbers in the date. If you use "." to separate the numbers in 
the date, the order is day month year. The year can be specified 
with either the last two digits or all four digits. If you 
specify the last two digits, the year is assumed to be in the 
range 1980 through 2079. The month must be expressed as a number 
between 1 and 12. Leading zeros on month and day are optional. 
If you specify just a number of days instead of month, day, and 
year, then the date indicated is that number of days before the 
current date.

For example, the following commands all copy everything with a 
file date on or after December 25, 1991 from the current 
directory to D:\SAVE\.

MCP /D12/25/91 *.* D:\SAVE\

MCP /D:12/25/91 *.* D:\SAVE\

MCP *.* D:\SAVE\ /D12/25/1991

MCP /D12-25-91 *.* D:\SAVE\

MCP *.* /D12-25-1991 D:\SAVE\

MCP /D25.12.91 *.* D:\SAVE\

MCP /D:25.12.1991 *.* D:\SAVE\

To copy everything in the current directory dated on or after 30 
days ago to D:\NEWSTUFF\,

MCP /D30 *.* D:\NEWSTUFF\

To copy everything in the current directory dated earlier than 
thirty days ago to D:\OLDSTUFF\,

MCP /D-30 *.* D:\OLDSTUFF\

To move all .DOC files in the current directory dated more than 
90 days ago to E:\ARCHIVES\,

MCP /R /D-90 *.DOC E:\ARCHIVES\

To copy everything in the current directory dated earlier than 
31 December 1994 to C:\1994\,

MCP /D-31.12.94 *.* C:\1994\

/F Forces overwriting of Hidden, System, and Read Only files. 
WARNING:  use this option with caution. It is very useful for 
some situations, but could have some undesired side effects if 
you overwrite some files of this type.

/H (Hidden & system) allows files with the system and hidden 
attribute to be copied. Note that the XCOPY that comes with 
MS-DOS 5.0 and MS-DOS 6.0 will not copy hidden files, but 
earlier versions will. The system and hidden attributes will be 
applied to the destination files when they are present in the 
source files. Note:  copying the two hidden system files from a 
boot drive to another drive will not necessarily make the 
destination bootable. Use the DOS SYS command for that purpose.

/J (Just existing) causes only those files that already exist in 
the destination directory to be copied over (and then only if 
they are older, the /o switch is used, or the /b switch is used 
and you answer Y for yes).

/L (Loud) causes extra screen output to be generated, including 
the names of all files that are skipped.

/N (No overwrite) prevents any destination files from being 
overwritten, regardless of the file dates and attributes 
involved. The default is to allow overwrites of destination 
files with an earlier file date. This is the opposite of /O 
(Overwrite always).

/O (Overwrite always) causes destination files to be overwritten 
regardless of its file date. The default is to allow overwrites 
only of destination files with an earlier file date. This is the 
opposite of /N (No overwrite).

/P (Prompt) asks you if you want to copy each file with a Y/n 
prompt. "N" or "n" will cause the file to be skipped. Most other 
keys, including "Y" and "y" will cause the file to be copied. 
The "Enter" key need not be pressed after the "y" or "n".

For example,

MCP /P *.* A:

lets you pick exactly which files you want to copy to drive A:, 
one by one.

/Q (Quiet) suppresses all screen output except for error 
messages and the help screen in response to a command line error 
or /?.

For example,

MCP /Q /M C:\WORK\*.* F:\MASTER\FRED\

in a network login script would be a subtle way to back up some 
critical directory on a user's hard disk to a network directory, 
where it could be moved to tape or something.

/R (Rename or move) causes files to be renamed if the source and 
destination are on the same disk, or copied then the original 
deleted (after a successful copy) if the source and destination 
are on different disks. If the copy fails, the original is left 
intact. When used with the /S option, emptied subdirectories are 
not removed.

For example,

MCP C:\STUFF\*.DOC D:\OLDJUNK\ /R

moves every .DOC file in C:\STUFF\ to D:\OLDJUNK\.

/S or /E (Subdirectory copy) copies files and subdirectories 
from the destination to the source, making subdirectories as 
needed. Empty subdirectories are created as well. Using /S 
and/or /E on the command line of MCP is the same as using both 
/S and /E on the command line of XCOPY.

/U (Update) overrides a previous /o, /b, or /n on the command 
line and returns MCP to its default handling of existing 
destination files (overwrite them only if they are older).

/V does nothing. To turn verify on, use the command VERIFY ON 
before running MCP.

/W (Wait) causes the prompt "Press a key when ready to start 
copy..." to be displayed, and the program to pause until you hit 
a key before starting the copy process. This is for use with 
floppy only systems, where the MCP command may reside on a disk 
other than the one you want to do the copy on.

/? (Help) shows the help screen.

MOVING FILES

Since moving files is a fairly common operation, you may want to 
define a doskey alias to move files (DOSKEY MV=MCP /R $*) or use 
the MV.BAT batch file. If you are using a version of DOS prior 
to 3.3, delete the @ from the beginning of the MCP command. This 
command lets you move files safely. Note that the original file 
will not be deleted if it is marked as "system" or "read only."  
Note also that when moving entire directory structures, source 
subdirectories are not deleted. To delete entire directory 
structures or to delete system or read only files, you can use 
the DELETE command (also written by Mike Johnson).

ZERO LENGTH FILES

Unlike XCOPY, MCP copies zero length files and, if copying 
subdirectories, always copies empty subdirectories. It also 
duplicates the file attributes (system, hidden, read only) of 
the source file in the destination file, except for the archive 
bit, which is always set in the destination file.

PROMPTS

There are several prompts possible in MCP. At each of the 
prompts, the default answer (if applicable) is indicated with a 
capital letter. Answers to the prompts are not case sensitive, 
and are all only one keystroke. Pressing "Enter" after a letter 
is not required. The "Enter" key is ignored at all prompts 
except for the "Press a key when ready to start copy . . ." 
prompt caused by the /W option. In addition to the listed 
responses at any prompt, "Esc", "Ctrl-C", and "Ctrl-Break" will 
terminate MCP. "Ctrl-Break" will also terminate a copy in 
progress, even if the program is not looking for an answer to a 
question.

filename Y/n?

This is the format used in asking if you want to copy a 
particular file when you put /P on the command line. "N" means 
that you do not want to copy the file, and most other keys 
(including "Y") mean that you do want to copy the file.

Only 512 bytes available on A:. filename requires 1234 bytes. 
Retry with new disk, Try new disk later, Skip, or Cancel 
(r/T/s/c)?

If your destination is on a fixed disk, press "S" to skip just 
this file or "C" to cancel and exit MCP. If your destination is 
a removable disk, you may skip the current file or cancel as 
with a fixed disk destination. You may also wish to change disks 
and then press "R" to retry copying the current file, or press 
"T" to try copying the next file (which may fit) and add the 
current file to a list to be tried again later (on a different 
floppy disk). Most other keys act the same as "T".

No more room on drive A:

Retry with new disk, Skip or Cancel (R/s/c)?

Your destination disk has no more room on it. Change the disk 
and press "R" to retry, or "C" to exit the MCP program.

Error writing to filename.

Retry, Skip, or Cancel (r/S/c)?

MCP encountered one of many possible errors (insufficient 
network rights, bad disk sectors, hardware failures, disk full 
even though it had enough room to start the copy, etc.). "R" 
restarts the copy from the beginning of the file. "S" skips this 
file and tries the next. "C" cancels the copy and exits MCP.

Does destination specify a File name

or Directory on the target (f=File, D=Directory)?

The destination directory is not an existing directory and the 
name does not end with "\", and there may be more than one 
source file (indicated by wild cards in the name or a /S or /E 
switch). Press "F" if you intended that the destination is a 
file name, or "D" if you intended that the destination is a 
directory. If you decide that the command line was in error, 
press "Esc".

Press a key when ready to start copy . . .

You used the /W option. Press "Esc", "Ctrl-C", or "Ctrl-Break" 
if you decide you really didn't want to copy anything after all, 
or press any other key to start the copy process.

ERROR MESSAGES

No matching files found.

No files matching the file specification you provided were found 
to copy. Check the spelling of your source file(s), the 
existence of those files, and the network rights pertaining to 
those files.

Break!

You pressed Ctrl-Break, Ctrl-C, or Esc to halt the program.

Unable to create filename

The destination file name may have been on an invalid drive, 
have contained invalid characters, been in the root directory 
with all directory entries filled, been on a network directory 
with insufficient rights, been too long for DOS or the network 
operating system to create, or some other similar problem.

Files may not be copied onto themselves.

The first step in copying a file is to create a new file of zero 
length with name of the destination file. If the source and 
destination files are the same, this action would destroy the 
source file. It is also possible to get this error message when 
the source or destination drive is invalid.

Destination path is too long.

The most likely cause of this error message is starting a 
recursive copy command (like MCP /S C:\*.* C:\SUBDIR\). This 
causes everything in the root directory of drive C: to be copied 
to C:\SUBDIR\ and C:\SUBDIR\SUBDIR\ and C:\SUBDIR\SUBDIR\SUBDIR\ 
and so on. Older versions of XCOPY allow this, the latest one 
does not. MCP allows the recursion to go on until the resulting 
path name exceeds DOS limits. This is a great way to fill up a 
hard disk in a hurry.

Not enough memory to run MCP.EXE

Try reducing the number of TSR programs, or if you are shelled 
out to DOS from another program, exit that other program.

Access denied.

DOS (or some network software) returned an error code indicating 
that the operation was not allowed. Some things that can do this 
is trying to create a directory when a file with the same name 
already exists or trying to write to a network directory where 
you have insufficient rights.

Bad file number.

Something strange is going on that confused DOS and/or MCP, 
probably some error associated with a multitasking environment.

Attempt to copy more than one file to file.

MCP does not concatenate files (use DOS COPY to do that), so 
copying more than one file to a single file means that all that 
ends up in the destination file is the last file copied. If this 
were done with the /R option, all but the last file would be 
destroyed. Therefore, only one file is allowed to be copied to a 
file. The trap that catches this is not foolproof (although it 
is reasonably difficult to fool), so you should still take care 
on the command line to avoid specifying such an action.

Unable to open filename

The specified file name may not be valid, or may be on a network 
directory where you have insufficient rights.

Ran out of memory keeping track of files to retry.

Each file name source and destination that is "remembered" to 
try later when you run out of room copying to a diskette takes 
up some conventional RAM. After several thousand of these (more 
or less, depending on how much RAM you have available), you may 
run out.

ERRORLEVEL

When running MCP in a batch file, you can test for the following 
values of ERRORLEVEL after MCP runs:

0 = Normal completion.

1 = No matching files found to copy.

2 = "Ctrl-Break", "Ctrl-C", or "Esc" pressed, or copy canceled 
with "C".

3 = Unable to write to destination file.

4 = Attempted to copy file onto itself.

5 = Destination path is too long.

6 = Not enough memory to run.

7 = Access denied.

8 = Bad file number error returned by DOS.

9 = Attempt to copy more than one file to one destination file.

11 = Command line error or help requested.

12 = Unable to open input file.

13 = Ran out of memory keeping track of files to retry.

NAME TRIVIA

MCP comes from M as in Master or Mike's and CP as in the name 
for the UNIX copy command. Call it whatever you like, by 
renaming it, creating an alias with DOSKEY or a similar utility, 
or by creating a batch file.

INTEGRITY CHECKS

To see if the files in this distribution have been damaged, 
hacked, altered, or infected since leaving the author's 
computer, you can check the files in this distribution with the 
command (note the lower case cv):

MD5SUM -cv MCP.ASC

This will check the files listed in MCP.ASC to see if they still 
have the same MD5 "fingerprints." To check that MCP.ASC hasn't 
been altered, you can use the Pretty Good Privacy program (PGP 
-- also available on the Colorado Catacombs BBS, 303-772-1062) 
to check the digital signature on MCP.ASC against my public key 
(in MPJ8.ASC).

PGP MPJ8.ASC

PGP MCP.ASC

This may not be 100% foolproof, but it is better than the 
hackable "security envelopes" of PKZIP and ARJ, and it rules out 
the accidental mistakes, anyway.

LIMITATIONS

MCP does not do concatenation. It does not get the date format 
from the DOS country table. It does not do Japanese dates in 
year-month-day format. All of its error messages are in English. 
It does not do a full screen interface. It doesn't skip zero 
length files just because they are zero length. It doesn't skip 
creation of empty subdirectories when /S is used. /V does 
absolutely nothing (use the DOS command VERIFY ON before MCP for 
the same effect). It doesn't remove any subdirectories, nor does 
it preserve subdirectory attributes (like the hidden bit) when 
copying subdirectories. It does not copy to devices like LPT1 or 
PRN. It cannot copy from defective disk media. It doesn't 
predict winning lottery numbers. On the other hand, it does do 
some things that I always thought that XCOPY should have done. 

LEGAL NOTICES

Copyright (C) 1992-1995 Michael Paul Johnson. All rights 
reserved. No warranty. All trademarks mentioned herein belong to 
their respective owners. This is shareware. To register, please 
send $15.00 (or $25.00 if you also want original disks & printed 
documentation; $100 for site license for unlimited use within 
one corporation) to:

        Mike Johnson
        PO BOX 1151
        LONGMONT CO 80502-1151
        USA

Registration entitles you to support on the Colorado Catacombs 
BBS (303-772-1062) and by mail, and to notification of major 
upgrades at discount rates. Upgrades for registered users are 
free for the downloading from the Colorado Catacombs BBS, or 
available by mail to registered users on disk for $10.

Although I try to write perfect software, there is a chance that 
I goofed up in some way. If you find this to be the case, please 
let me know so that I can repair it. Because I can't test every 
possible use of this software on every system that it might be 
run on, and because I have no control over the way shareware 
gets passed around, you use this software entirely at your own 
risk. Prices are subject to change without notice.

HOW TO CONTACT THE AUTHOR

1. Leave a message at the Colorado Catacombs BBS, 303-772-1062. 
The latest version of this software will be posted there, as 
well.

2. Write to Mike Johnson, PO Box 1151, Longmont CO 80502-1151, 
USA.

3. Send electronic mail to CompuServe ID 71331,2332 or Internet 
address m.p.johnson@ieee.org.

4. Call Mike Johnson at home at 303-772-1773.

VERSION HISTORY

1.00  5 Sep 92  Initial release.

1.01  7 Sep 92  Modified to allow recursive copies of hidden 
subdirectories.

1.02  9 Sep 92  Corrected handling of . and .. as source or 
destination directory name.

1.03 20 Sep 92  Added /C switch to specify overwrites of all but 
identical files.

1.04 22 Sep 92  Added /B switch to allow individual prompts for 
overwrites.

1.05  5 Oct 92  Improved safety feature that prevents copying or 
renaming more than one file to the same destination file. Added 
/J switch to allow selective copying only of files that already 
exist in the destination directory.

1.06 11 Dec 92  Added /T switch for better results with 
redirected output.

1.07 14 Dec 92  Corrected command line scanning error that 
sometimes caused /D switch to be falsely rejected.

1.08  6 Feb 93  Increased depth of recursion possible for better 
network compatibility.

1.09 31 May 93  Corrected action with /P and /R when moving to a 
destination on the same volume.

1.10  3 Jul 93  Added warning message and ERRORLEVEL 1 exit if 
no source files match the specification on the command line.

1.20  2 Oct 93  Added /I switch.

1.50  5 Feb 95  Added /D- option. Added /Ddays option. Changed 
support BBS name and phone number to Colorado Catacombs BBS, 
303-772-1062. Added MD5SUM integrity check files to distribution 
archive. Changed from PostScript to Microsoft Windows Write 
format for distributing the manual.

INVOICE

Remit to:                       Ship to:

Mike Johnson                    ________________________________

PO Box 1151                     ________________________________

Longmont CO 80502-1151          ________________________________

USA                             ________________________________

                                Contact person:

                                ________________________________

                                ________________________________

                 email address: ________________________________

Quantity        Description                                     
Unit Price      Total

                MCP registration with disk
________        & printed documentation.          $25.00  ______

                MCP single copy registration
________        only.                             $15.00  ______

                Site license for unlimited use
                of MCP at one corporation
                (includes one disk & one
________        printed manual).                 $100.00  ______

                                                   Total  ______

I prefer        5.25"____   3.5"____  disks.

Note that the MCP software has been delivered and accepted by 
the customer. Upon receipt of this paid invoice, the printed 
documentation and disks paid for will be sent.

MCP 1.50        February 5, 1995

