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.

/ACopies only files with the archive attribute
set, doesn’t change the attribute.
/MCopies only files with the archive attribute
set, turns off the archive attribute.
/D:m-d-yCopies 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.
/PPrompts you before creating each destination
/SCopies directories and subdirectories except
empty ones.
/ECopies directories and subdirectories,
including empty ones. Same as /S /E. May be used to modify /T.
/VVerifies each new file.
/WPrompts you to press a key before copying.
/CContinues copying even if errors occur.
/IIf destination does not exist and copying more
than one file, assumes that destination must be a directory.
/QDoes not display file names while copying.
/FDisplays full source and destination file
names while copying.
/LDisplays files that would be copied.
/HCopies hidden and system files also.
/ROverwrites read-only files.
/TCreates directory structure, but does not copy
files. Does not include empty directories or subdirectories.
/T /E includes empty directories and subdirectories.
/UCopies only files that already exist in
/KCopies attributes. Normal Xcopy will reset
read-only attributes.
/NCopies using the generated short names.
/OCopies file ownership and ACL information.
/XCopies file audit settings (implies /O).
/YSuppresses prompting to confirm you want to
overwrite an existing destination file.
/-YCauses prompting to confirm you want to
overwrite an existing destination file.
/ZCopies 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