Program: DCOPY Author: Marty Peritsky E-mail: k3pbu@epix.net (preferred address) or MMTed@aol.com (alternate) Maintainers: Joe Cosentino (j_cosentino@hotmail.com) and Mark Willis (mwillis@.net) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Purpose: Copies or concatenates files. Syntax: DCOPY /?|/H DCOPY [optns] dev|srcspec[+srcspec...] [optns] [dev|destspec [optns]] dev is device AUX, COMn, CON, LPTn, NUL, or PRN srcspec source device, file or list of files (wildcards allowed) destspec destination file or device optns /A process file as ASCII (Ctrl-Z indicates end-of-file) /B process file as binary (no special handling of Ctrl-Z) /C request confirmation before processing /K keep newer files (don't overwrite them) /R replace existing files (don't copy others) /S copy system or hidden files /V verify that destination was written without errors /W warn if destination file already exists /Z zero the high-order bit of every byte in destination Examples: DCOPY fileA+fileB fileC DCOPY *.exe c:mydir Comments: If your system's command processor (eg, COMMAND.COM) has a built-in COPY command, you can rename COPY.EXE to something else, say FCOPY.EXE. This program automatically determines its own name, and displays its messages with the correct name. Even if you use the built-in command for normal copying, you may find this program, with its /K and /R switches, to be a handy "backup" utility. This program is similar to (but not identical to) the built-in COPY command in that other operating system, denoted (Not Free) DOS or NF-DOS for short. The COPY command in NF-DOS is simple on the surface, but actually quite complicated in some of its details. (If you don't believe this, take the quiz in Appendix A, below.) In general, this program is simpler, and obeys the following rules: 1. The default mode is always "binary", not "ascii". 2. Source files are opened in the same order that they appear on the command line (ie, left-to-right). If the specification contains wildcards, the files are opened in the order in which they appear in the directory. 3. The program will append (concatenate) files if and only if the source specifies multiple files and the destination does not. This rule implies that the symbol "+" is just a separator, and does not force concatenation. See Appendix B for more details and examples of how this rule works. 4. Concatenating a mix of ascii and binary files cannot be specified. In other words, the "/A" or "/B" appearing before the source specification applies to all the source files. Usually, this program will perform the same as NF-DOS COPY in simple cases. Ambiguous or peculiar constructions involving wildcards may produce different results, generally because the source files are opened in a different order. Examples where results may differ: DCOPY *.C+*.H *.Z DCOPY *.C+*.H ALL.Z DCOPY *.C Z.* DCOPY *.* Z?Z*.Z* APPENDIX A -- A Short Quiz Assume that the current directory contains the following files: UUU.C VVV.C VVV.H VVV.Z WWW.C WWW.H XXX.H If you run the following command in (Not Free) DOS, what files result, and what will each one contain?: DCOPY *.C+*.H *.Z Give up? Try it; you'll probably be surprised at the result, which shows some subtle complexity in the order in which files are processed. Second question: Where is this documented? (Answer: nowhere that I have seen.) APPENDIX B -- More about Appending vs. Copying This program looks for the presence of wildcard characters ('?' and '*') in the destination specification. If it finds any wildcards, it assumes that you intend to copy to multiple destination files, rather than append. Usually that is a valid assumption, but you should be careful with wildcards to avoid doing something that you don't want to do. Consider the following command: DCOPY A.X+A.Y A.Z Because the above command does not have any wildcards in the destination specification, the program will concatenate A.X with A.Y and place the result in A.Z. Now consider a similar command: DCOPY A.X+A.Y *.Z Because the destination specification contains '*', the program assumes that it should be copying rather than appending, so it first copies A.X to A.Z, and then copies A.Y, overwriting A.Z. The final result is that A.Z will be identical to A.Y, which probably was not intended! To avoid this kind of problem, always remember to use a non-wildcard destination specification if you are concatenating files.