How to Use the Xcopy Command in Windows

Last Updated : 12 Feb, 2026

The Xcopy command in Windows is an advanced file-copying tool that allows you to copy entire directories, including all subfolders and files. It goes beyond the basic copy command by supporting large-scale data transfers and automated file operations. This makes Xcopy ideal for tasks that require efficiency, flexibility, and control over how files are copied.

Why xcopy is useful:

  • Copies complete directories with subdirectories and files
  • Ideal for backups, data migrations, and file replication
  • Supports many options for automation and customization
  • Offers more control than the standard copy command

Basic Syntax:

xcopy [source] [destination] [options]

  • [source]: The path to the file or directory we want to copy.
  • [destination]: The path to where we want to copy the files.
  • [options]: The Various flags that control how the Xcopy command behaves.

How to Use the Xcopy Command?

1. Copy Files

To copy a single file:

xcopy C:\source\file.txt D:\destination\

This copies file.txt into D:\destination.

Example:

8

2. Copy an Entire Directory

Use /s to copy all subdirectories except empty ones:

xcopy C:\source\ D:\destination\ /s

Example:

8

3. Copy Directory Including Empty Folders

Use /e to include empty subdirectories:

xcopy C:\source\ D:\destination\ /e

Example:

8

4. Copy and Overwrite Files Automatically

Suppress overwrite prompts using /y:

xcopy C:\source\ D:\destination\ /y

Example:

8

5. Copy Files Based on Modified Date

Copy only files that are newer or modified using /d:

xcopy C:\source\ D:\destination\ /d

This saves time and storage during backups.

Example:

8

6. Copy Files Quietly

To hide output and suppress file listing:

xcopy C:\source\ D:\destination\ /q

Example:

8

7. Copy System and Hidden Files

Use /h to copy files normally skipped:

xcopy C:\source\ D:\destination\ /h

Normally, hidden and system files are not copied. The /h switch forces the Xcopy command to the include them.

Example:

8

8. Verify Files After Copying

Use /v to ensure copied files match the source:

xcopy C:\source\ D:\destination\ /v

Example:

8

9. Avoid Destination Confirmation Prompt

When xcopy is unsure if the destination is a file or folder, use /i:

xcopy C:\source\ D:\destination\ /i

Example:

8

Common Xcopy Options

Here are some commonly used Xcopy options:

OptionDescription
/sCopies directories and subdirectories except empty ones
/eCopies all subdirectories, including empty ones
/yOverwrites files without prompting
/dCopies only files newer than the destination
/vVerifies files after copying
/hCopies hidden and system files
/qQuiet mode suppresses output
/iAssumes destination is a directory
/fDisplays full source and destination paths
Comment