copy file in cmd code example

Example 1: cmd copy file

Syntax
      COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination [/A|/B]]
      COPY source1 + source2.. destination [options]
Key
     source :  Pathname for the file or files to be copied.
        /A  :  ASCII text file (default)
        /B  :  Binary file copy - will copy extended characters.
        /D  :  Allow the destination file to be created decrypted.
destination :  Pathname for the new file(s).
        /V  :  Verify that the destination file, once written, can be read.
               No comparison with the source files occurs. 
        /N  :  If at all possible, create only short filenames (8.3) in the
               destination. This option can help when copying between disks
               that are formatted differently e.g NTFS and VFAT, or when archiving 
               data to an ISO9660 CDROM.
        /L  :  If source is a symbolic link copy the link to the target
               instead of the actual file the source link points to.
        /Y  :  Suppress confirmation prompt, when overwriting files.
        /-Y :  Enable confirmation prompt, when overwriting files.
        /Z  :  Copy files in restartable mode. If the copy is interrupted
               part way through, it will restart if possible. (use on slow networks)

Example 2: copy file command line

copy c:\data\file1.doc D:\backup\file2.doc

Example 3: copy command in cmd

COPY "filename" /Y
to overwrite the file in destination

Tags:

Misc Example