Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ copy(CMD) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 copy(CMD)                       19 June 1992                       copy(CMD)


 Name

    copy - copy one or more files to another location

 Syntax


    copy [/a|/b] source [/a|/b] [ +source [/a|/b] [+ ...]]
    [destination [/a|/b]] [/v]


 Description

    This command can also be used to combine files.  When more than one file
    is copied, MS-DOS displays each filename as the file is copied.

 Parameters


    source Specifies the location and name of a file or set of files from
           which you want to copy.  source can consist of a drive letter and
           colon, a directory name, a filename, or a combination.

    destination
           Specifies the location and name of a file or set of files to which
           you want to copy.  destination can consist of a drive letter and
           colon, a directory name, a filename, or a combination.


 Switches


    /a     Indicates an ASCII text file.  When the /a switch precedes the
           list of filenames on the command line, it applies to all files
           whose names follow the /a switch, until copy encounters a /b
           switch, in which case the /b switch applies to the file whose name
           precedes the /b switch.  When the /a switch follows a filename, it
           applies to the file whose name precedes the /a switch and to all
           files whose names follow the /a switch, until copy encounters a /b
           switch, in which case the /b switch applies to the file whose name
           precedes the /b switch.  An ASCII text file can use an end-of-file
           character (CtrlZ) to indicate the end of the file.  When combining
           files, copy treats files as ASCII text files by default.

    /b     Indicates a binary file.  When the /b switch precedes the list of
           filenames on the command line, it applies to all files whose names
           follow the /b switch, until copy encounters an /a switch, in which
           case the /a switch applies to the file whose name precedes the /a
           switch.  When the /b switch follows a filename, it applies to the
           file whose name precedes the /b switch and to all files whose
           names follow the /b switch, until copy encounters an /a switch, in
           which case the /a switch applies to the file whose name precedes
           the /a switch.  The /b switch specifies that the command inter-
           preter is to read the number of bytes specified by the file size
           in the directory.  The /b switch is the default value for copy
           unless copy is combining files.

    /v     Verifies that new files are written correctly.


 Notes


    Copying to and from devices

    You can substitute a device name for one or more occurrences of source or
    for destination.

    Using or omitting the /b switch when copying to a device

    When destination is a device (for example, COM1 or LPT1), the /b switch
    causes MS-DOS to copy data to the device in binary mode.  In binary mode,
    all characters (including such special characters as CtrlC, CtrlS, CtrlZ,
    and carriage return) are copied to the device as data.  Whereas, omission
    of the /b switch causes MS-DOS to copy data to the device in ASCII mode.
    In ASCII mode, such special characters as those previously listed may
    cause MS-DOS to take special action during the copying process.

    Using the default destination file

    If you do not specify a destination file, MS-DOS creates a copy with the
    same name, creation date, and creation time as the original file, placing
    the new copy in the current directory on the current drive.  If the
    source file is on the current drive and in the current directory and you
    do not specify a different drive or directory for the destination file,
    the copy command stops and MS-DOS displays the following error message:

       File cannot be copied onto itself
       0 File(s) copied


    Using the /v switch

    If MS-DOS cannot verify a write operation, it displays an error message.
    Although recording errors rarely occur with the copy command, the /v
    switch lets you verify that critical data has been correctly recorded.
    The /v switch also slows down the copy command, because MS-DOS must check
    each sector recorded on the disk.

    Using the /a and /b switches

    The effect of an /a or /b switch depends upon its position on the command
    line.  When the /a or /b switch follows the source filename, copy per-
    forms as shown in the following list:

    /a     Treats the file as an ASCII (text) file and copies data that pre-
           cedes the first end-of-file character.  copy does not copy the
           first end-of-file character or the remainder of the file.

    /b     Copies the entire file, including any end-of-file character.

    When the /a or /b switch follows the destination filename, copy performs
    as shown in the following list:

    /a     Adds an end-of-file character as the last character of the file.

    /b     Does not add an end-of-file character.


    Combining files with the copy command

    If you specify more than one source, separating entries with a plus sign
    (+), copy combines the files, creating a single file.  If you use wild-
    cards in source but specify a single filename in destination, copy com-
    bines all files matching the filename in source and creates a single file
    with the filename specified in destination.

    In either case, copy assumes the combined files are ASCII files unless
    you specify the /b switch.

    If the name of the destination file is the same as the name of one of the
    files being copied (except the first file), the original contents of the
    destination file are lost.  When this happens, copy displays the follow-
    ing message:

       Content of destination lost before copy


    Copying files in subdirectories

    To copy all of a directory's files and subdirectories, you should use the
    xcopy(CMD) command.

    Copying zero-length files

    copy does not copy files that are 0 bytes long.  Use xcopy(CMD) to copy
    these files.

    Changing the time and date of a file

    If you want to assign the current time and date to a file without modify-
    ing the file, use a command in the following format.  The commas indicate
    the omission of the destination parameter.

       copy /b source+,,


 Examples

    The following command copies a file and ensures that an end-of-file char-
    acter is at the end of the copied file:

       copy memo.doc letter.doc /a


    To copy a file named ROBIN.TYP from the current drive and directory to an
    existing directory named BIRDS that is located on drive C, type the fol-
    lowing command:

       copy robin.typ c:\birds


    If the BIRDS directory does not exist, MS-DOS copies the file ROBIN.TYP
    into a file named BIRDS that is located in the root directory on the disk
    in drive C.

    To copy several files into one file, list any number of files as source
    parameters on the copy command line.  Separate filenames with a plus sign
    (+) and specify a filename for the resulting combined file, as the fol-
    lowing example shows:

       copy mar89.rpt + apr89.rpt + may89.rpt report


    This command combines the files named MAR89.RPT, APR89.RPT, and MAY89.RPT
    from the current drive and directory and places them in a file named
    REPORT in the current directory on the current drive.  When files are
    combined, the destination file is created with the current date and time.
    If you omit destination, MS-DOS combines the files and stores them under
    the name of the first specified file.  For example, if a file named
    REPORT already exists, you can use the following command to combine all
    four files in REPORT:

       copy report + mar89.rpt + apr89.rpt + may89.rpt


    You can also combine several files into one by using wildcards, as the
    following example shows:

       copy *.txt combin.doc


    This command combines all files in the current directory on the current
    drive that have the extension .TXT into one file named COMBIN.DOC, also
    in the current directory on the current drive.

    If you want to combine several binary files into one by using wildcards,
    include the /b switch, as the following example shows:

       copy /b *.exe combin.exe


    This prevents MS-DOS from treating CtrlZ as an end-of-file character.

    _________________________________________________________________________
       CAUTION  If you combine binary files, the resulting file might not
       be usable due to internal formatting.
    _________________________________________________________________________


    In the following example, copy combines each file that has a .TXT exten-
    sion with its corresponding .REF file.  The result is a file with the
    same filename but with a .DOC extension.  Thus, copy combines FILE1.TXT
    with FILE1.REF to form FILE1.DOC.  Then copy combines FILE2.TXT with
    FILE2.REF to form FILE2.DOC, and so on.

       copy *.txt + *.ref *.doc


    The following copy command combines first all files with the .TXT exten-
    sion, then all files with the .REF extension into one file named
    COMBIN.DOC:

       copy *.txt + *.ref combin.doc


 Related command

    For information about copying directories and subdirectories, see the
    copy(CMD) command.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026