Copying Data with XCopy

Written by Barry Dysert (last updated October 23, 2017)

2

XCopy is a command-line utility that comes with Windows. It offers a great deal more functionality than the familiar COPY command, but of course the additional functionality makes XCopy a bit more difficult to use than COPY. This tip provides information on some of its more interesting features so that you can begin using it with very little learning curve.

XCopy provides an easy way to copy both files and directory trees. Its basic syntax is:

C:\> XCOPY source destination [switches]

The /E switch is very useful. It is used to copy directories and subdirectories. So, for example, if you had a directory named C:\Temp\Barry which contained files and subdirectories, you could duplicate Barry's tree structure (i.e., copying all its files and subdirectories) to C:\Temp2 with this command:

C:\> XCOPY C:\Temp\Barry C:\Temp2 /E

Another useful switch is /C, which tells XCopy it should continue copying even if errors occur.

If you're not quite sure what your XCopy command is going to copy, you can simply pretend to execute it, and instead of copying anything it will tell you what it would have copied. This is accomplished by the /L switch.

The /Z switch is very good to know about, especially if you're copying large files over a network. This switch means the copy is "restartable", meaning that if it is interrupted, it can be resumed from where it got cut off instead of having to start copying all over again. While you're at it, I suggest you add the /J switch for copying large files. This switch tells XCopy to use unbuffered I/O, which makes copying of large files goes faster.

There are several other switches to XCopy, mainly having to do with whether to suppress messages or confirmations, deal with files' attributes, and excluded files. A complete list of switches can be obtained by specifying /? on the command line:

C:\> XCOPY /?

 This tip (13226) applies to Windows 7, 8, and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 35 years, working in different positions such as technical team leader, project manager, and software developer. He is currently a software engineer with an emphasis on developing custom applications under Microsoft Windows. When not working with Windows or writing Tips, Barry is an amateur writer. His first non-fiction book is titled "A Chronological Commentary of Revelation." ...

MORE FROM BARRY

Disabling Automatic Reboot after a Windows Update

It may not always be a good thing to have Windows automatically restart your computer after an update. This tip tells you ...

Discover More

Using File History

Backing up your data is an important part of computer management. Enabling File History is a painless way to be able to ...

Discover More

Renaming or Deleting File Folders

Just as you can rename and delete individual files, so to can you rename and delete the folders that contain those files.

Discover More
More WindowsTips

Creating a CD/DVD Archive

CDs and DVDs are good for creating archives of files you want to keep over the long term. They are a great way to back up ...

Discover More

Creating a Hierarchy Map of Your Hard Drive

Want to see how the directories and subdirectories in your hard drive are organized? It's easy to do using the directions ...

Discover More

Deleting Files or Folders

Part of managing the files and folders on a system is the need to occasionally delete them. Here's a quick discussion on ...

Discover More
Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight less than 8?

2017-10-24 07:32:46

Barry

There are some Tips here about Robocopy as well. You might want to read them and decide for yourself which you prefer. (And your colleague is right about the warning.)


2017-10-24 07:09:47

Alex B

I mentioned this to one of our tech guys and he suggested I use Robocopy. Also a command-line utility and even more flexible and yes therefore also more difficult. His parting warning was not to use the purge or mirroring options since they can cause you to lose files in the process.


Newest Tips