The xcopy command is a Command Prompt command used to copy one or more files or folders from one location to another location.

With its many options and ability to copy entire directories, it’s similar to, but much more powerful than, the copy command. The robocopy command is also similar but has even more options.

Xcopy Command Availability

This command is available from within the Command Prompt in all Windows operating systems including Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows 98, etc.

You can also access the command in MS-DOS as a DOS command.

Xcopy Command Syntax

Use the following syntax for the xcopy command:

xcopy source [destination] [/a] [/b] [/c] [/d [:date]] [/e] [/f] [/g] [/h] [/i] [/j] [/k] [/l] [/m] [/n] [/o] [/p] [/q] [/r] [/s] [/t] [/u] [/v] [/w] [/x] [/y] [/-y] [/z] [/exclude:file1[+file2][+file3]…] [/?]

The availability of certain xcopy command switches and other command syntax may differ from operating system to operating system. Learn how to read command syntax if you’re not sure how to read the syntax above or in the table below.

Xcopy Command Examples

Following are several examples of how to use this command:

The xcopy command will add the archive attribute to files in destination no matter if the attribute was on or off on the file in source.

Copy Files to a New Folder

xcopy C:\Files E:\Files /i

In the above example, the files contained in the source directory of C:\Files are copied to destination, a new directory [/i] on the E drive called Files.

No subdirectories, nor any files contained within them, will be copied because the /s option was not used.

Xcopy Backup Script

xcopy “C:\Important Files” D:\Backup /c /d /e /h /i /k /q /r /s /x /y

In this example, xcopy is designed to function as a backup solution. Try this if you’d like to use xcopy instead of a backup software program to back up your files. Put the command as shown above in a script and schedule it to run nightly.

As shown above, the command is used to copy all the files and folders [/s] newer than those already copied [/d], including empty folders [/e] and hidden files [/h], from source of C:\Important Files to the destination of D:\Backup, which is a directory [/i]. We have some read-only files we want to keep updated in destination [/r] and we want to keep that attribute after being copied [/k]. We also want to make sure we maintain any ownership and audit settings in the files we’re copying [/x]. Finally, since we’re running xcopy in a script, we don’t need to see any information about the files as they’re copied [/q], We don’t want to be prompted to overwrite each one [/y], nor do we want the command to stop if it runs into an error [/c].

Copy Files and Folders Over the Network

xcopy C:\Videos “\SERVER\Media Backup” /f /j /s /w /z

Here, the command is used to copy all the files, subfolders, and files contained in the subfolders [/s] from source of C:\Videos to the destination folder Media Backup located on a computer on the network by the name of SERVER. We’re copying some really large video files, so buffering should be disabled to improve the copy process [/j], and since we’re copying over the network, we want to be able to resume copying if we lose the network connection [/z]. Being paranoid, we want to be prompted to start the process before it actually does anything [/w], and we also want to see every detail about what files are being copied as they’re being copied [/f].

Duplicate Folder Structure

xcopy C:\Client032 C:\Client033 /t /e

In this final example, we have a source full of well-organized files and folders in C:\Client032 for a client. We’ve already created an empty destination folder, Client033, for a new client but we don’t want any files copied—just the empty folder structure [/t] so that we’re organized and prepared. We have some empty folders in C:\Client032 that might apply to the new client, so we want to make sure those are copied as well [/e].

Xcopy & Xcopy32

In Windows 98 and Windows 95, two versions of the xcopy command were available: xcopy and xcopy32. However, the latter command was never intended to be run directly.

Save the sometimes lengthy output of the xcopy command to a file using a redirection operator. Learn how to redirect command output to a file or check out Command Prompt Tricks for more tips.

When you execute xcopy in Windows 95 or 98, either the original 16-bit version is automatically executed (when in MS-DOS mode) or the newer 32-bit version is automatically executed (when in Windows).

To be clear, no matter what version of Windows or MS-DOS you have, always run the xcopy command, not xcopy32, even if it’s available. When you execute xcopy, you’re always running the most appropriate version of the command.

The xcopy command is similar in many ways to the copy command but with significantly more options, like the ability to copy folders, copy every file in subdirectories, and exclude files.

This command is also very much like the robocopy command except that robocopy has more flexibility than even xcopy.

The dir command is often used with xcopy to check which folders and files are in a directory before completing the command.

Get the Latest Tech News Delivered Every Day

  • Copy Command

  • How to Restore Deleted Files From the Recycle Bin

  • How to Use the Netstat Command

  • Rename Command

  • Net Send Command

  • 21 Best Command Prompt Tricks

  • Vol Command Examples and Options

  • AOMEI Backupper Standard v7.1.2

  • Net Command

  • How to Change the Windows Startup Sound

  • More Command

  • The Complete List of Command Prompt (CMD) Commands

  • How to Redirect Command Output to a File

  • Sfc Command (System File Checker)

  • 31 Best Free Backup Software Tools

  • Windows 7 Command Prompt Commands

  • Facebook

  • Twitter

Hit Refresh on Your Tech News

  • About Us

  • Privacy Policy

  • Editorial Guidelines

  • Terms of Use

  • Careers

  • Advertise

  • Contact

  • EU Privacy

  • NEWS

  • HOW TO

  • FEATURES

  • ABOUT US