The copy command is primary command available in Dos as well as Linux operating system for organizing and making copies of files. Working with dos is relatively faster than working in windows environment. However copy command have several drawback. You can not copy complete disk or a folder with files and sub-directory in folder with copy command. Moreover copy process will be halted if problem persist in copying files in destination location. Even windows explorer does not ask to retry or skip file in case of problem. Linux is better in this case, at-least Linux ask user to retry, halt or skip file.

Dos support external XCOPY command for this purpose and support numerous switches. I use following command with switches to create a replica of one location.

C:/> xcopy d:\*.* h: /s /c /h

This command copy all files in D: drive to H: drive. The /s switch used to copy all directory and sub directories. /c used to continue copy with rest of directories and files even if error occurred.  /h used to copy hidden and system files.  Use /Y to overwrite file without prompt if file already exist in the destination directory.

xcopy support following switches that you can use for your own conveyance.

/A Copies only files with the archive attribute
set, doesn’t change the attribute.
/M Copies only files with the archive attribute
set, turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified
date. If no date is given, copies only those files whose
source time is newer than the destination time.
/P Prompts you before creating each destination
file.
/S Copies directories and subdirectories except
empty ones.
/E Copies directories and subdirectories,
including empty ones. Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more
than one file, assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file
names while copying.
/L Displays files that would be copied.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy
files. Does not include empty directories or subdirectories.
/T /E includes empty directories and subdirectories.
/U Copies only files that already exist in
destination.
/K Copies attributes. Normal Xcopy will reset
read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to
overwrite an existing destination file.
/-Y Causes prompting to confirm you want to
overwrite an existing destination file.
/Z Copies networked files in restartable mode.

Written by Bala Krishna

Bala Krishna is web developer and occasional blogger from Bhopal, MP, India. He like to share idea, issue he face while working with the code.

This article has 1 comments