Web Analytics

New to using the command prompt? Check out the Windows Command Prompt Beginner’s Guide

If you are looking to transfer lots of files, large files, a large amount of data, or a combination of the above, you should consider using Xcopy—a command line tool used to copy data.

In this guide, we’ll take a look at:

  1. The basic syntax of Xcopy.
  2. How to use parameters to refine Xcopy behavior.
  3. How to output Xcopy results to a text file.

I decided to write this guide after using Xcopy to transfer 1.2 TB of data from one drive to another after the first drive started failing on me. The advantage of using Xcopy is that you can automate responses to questions like (Do you want to overwrite this file) and also continue the copy process should you hit bad sectors on the drive (ordinarily this would either kill the copy process—in Windows XP—or ask you to Cancel the process or skip the file—Windows 7/Vista.)

Xcopy is a powerful tool and I hope to explain it in simple terms in this guide.

The Basic Syntax of Xcopy

To run Xcopy, open a command prompt (how do I run a command prompt?)

Type xcopy followed by the source location (red) and the destination location (orange)

i.e. xcopy g:\ u:\ will copy everything from the G drive to the U drive.

How to Use Parameters to Refine Xcopy Behavior

Parameters can be used to refine the copying process. These parameters (blue) are added after the source and destination folders to apply certain rules; below is an explanation of the ones I use the most (“cherkys”):

  • /c : Ignores errors.
  • /h : Copies files with hidden and system file attributes. By default, xcopy does not copy hidden or system files.
  • /e : Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options.
  • /r : Copies read-only files.
  • /k : Copies files and retains the read-only attribute on destination files if present on the source files. By default, xcopy removes the read-only attribute.
  • /y : Suppresses prompting to confirm that you want to overwrite an existing destination file.
  • /s : Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.

For more parameters, see the Microsoft Help page.

How to Output Xcopy Results to a Text File

If you want to create a text file with the results of the xcopy process (to check for any errors), you can add a parameter to create the text file (just like most commands.) Simply add >>out.txt (green) to the command (which will save the text file to the currently selected directory—in this case it’s C:\Users\Rich)

An example of using Xcopy | Example 2

Want to learn more about Xcopy? Check this Microsoft Help page.

About Rich

Rich is the owner and creator of Windows Guides; he spends his time breaking things on his PC so he can write how-to guides to fix them.

Free PC tips by email

Search Windows Guides


Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Subscribe now
Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Windows Guides on Facebook