The xcopy command copies files and whole folder trees from one location to another in Windows 11, and it can do things File Explorer's drag-and-drop cannot, such as copy only files that changed since the last copy, recreate the folder structure in one pass, and skip empty folders. To use it, open Command Prompt or Windows Terminal, type xcopy "source" "destination" [options], and press Enter. Nothing needs to be installed; xcopy has shipped with Windows for decades and is present on every Windows 11 install. The main thing you need is write access to the destination, and a backup if the source matters, because xcopy deletes files at the destination when told to and does not ask twice.

What You'll Need

  • A Windows 11 PC with Command Prompt or Windows Terminal (both are built in).
  • Read access to the source folder and write access to the destination.
  • The exact paths of both folders, ideally copied from File Explorer's address bar rather than typed by hand.
  • A backup of anything irreplaceable, especially before using options that overwrite or delete.
  • Administrator rights only if you are writing to protected areas such as C:\Program Files or another user's profile.

Note that menu labels and option behaviour can differ slightly between Windows versions, and xcopy options are case-insensitive but the / prefix is required. When in doubt, run xcopy /? to see the exact options on your machine.

Step-by-Step

  1. Open Command Prompt. Press the Windows key, type cmd, and choose Command Prompt. If you need administrator rights for the destination, right-click Command Prompt and choose Run as administrator. You can also use Windows Terminal, which is the default console host in Windows 11; the commands are identical.
  2. Copy the source path. In File Explorer, open the folder you want to copy, click the address bar, and copy the full path. If you want only certain files from that folder, note their names or wildcard pattern, for example *.jpg or report*.docx.
  3. Decide the destination path. Create the target folder first, or let xcopy create it. Wrap both paths in double quotes, because paths with spaces break the command otherwise.
  4. Run a basic copy. A plain folder copy with subfolders and no prompts looks like this:
    xcopy "C:\Users\Sam\Documents\Projects" "D:\Backup\Projects" /E /I /H /Y
    Here /E copies all subdirectories including empty ones, /I treats the destination as a directory and creates it if needed, /H includes hidden and system files, and /Y suppresses the overwrite prompt. Leave off /Y if you want to be asked before each overwrite.
  5. Watch the summary. When it finishes, xcopy prints how many files it copied. If it says zero files copied, the source path or the filter is wrong; check the quoting first.
  6. Use the update mode for repeat runs. For routine backups, /D copies only files whose source is newer than the destination copy, and /M copies only files with the archive bit set and then clears it. /D is the safer everyday choice because it compares timestamps rather than relying on an attribute that other tools may reset.
  7. Mirror a folder when you truly want an exact match. Adding /U to an update copy only handles files that exist in the source; combining options does not turn xcopy into a full mirror. For deleting destination files that no longer exist in the source, use robocopy with /MIR instead, since xcopy has no reliable mirror mode. Test any mirror operation on a scratch folder first.
  8. Copy a single file type. To copy just the images from a folder tree:
    xcopy "C:\Users\Sam\Pictures" "E:\PhotoBackup" *.jpg /S /Y
    /S copies subfolders but skips empty ones; use /E if you want the empty folders preserved as well.
  9. Check the result. Open the destination in File Explorer and confirm the folder structure and a sample of files. Compare file counts if the copy was large.

Common Mistakes

  • Leaving paths unquoted. C:\My Files\Photos is read as three separate arguments. Always wrap paths in double quotes.
  • Using a bare filename the wrong way. If the destination includes a filename with no extension specified, xcopy can append it to a folder name. Give the destination as a folder path ending in a backslash, or add /I, when you mean a folder.
  • Assuming xcopy deletes extras. It does not reconcile the destination with the source unless you deliberately use deletion switches, and those are dangerous. Never add them casually to a backup job.
  • Forgetting /H. Hidden files are silently skipped without it, which is a common reason a supposed full copy is incomplete.
  • Running from inside the source folder. Running xcopy with the working directory inside the source can cause it to try to copy itself into the destination. Run it from a neutral folder such as C:\.
  • Expecting it to handle very long paths. Paths beyond the classic limit can fail. Shorten the destination or use robocopy, which handles long paths and large trees more reliably.
  • Copying open files. Files locked by another program may be skipped. Close the program, or use a proper backup tool that supports shadow copies for live system files.

Tips

  • Add /F to see each source and destination filename as it copies, which makes a failed run much easier to diagnose.
  • Use /L to preview what would be copied without copying anything. It is the best way to test a complex command before committing.
  • Use /C to keep going after errors in a large job, then read the error lines at the end.
  • Press the Up arrow to recall the previous command and edit it rather than retyping paths.
  • For scheduled backups, put the command in a batch file and run it through Task Scheduler. That keeps the command out of reach of typos.
  • xcopy has been superseded by robocopy for heavy jobs. robocopy is faster on large trees, retries automatically, and can mirror safely with logging. Use xcopy for simple, quick copies and robocopy for anything big or repeated.
  • Run xcopy /? once and keep the output handy; the switches are the part people most often get wrong.

Troubleshooting

"Invalid number of parameters." A path contains a space without quotes, or two paths were passed where one was expected. Re-copy the full paths and quote them.

"File not found." Check the source path character by character, confirm the drive letter exists, and test with dir "path" before running xcopy.

"Access denied." The account lacks permission on the source or destination, or the file is open in another program. Close the program, or reopen Command Prompt as administrator if the destination is protected.

Nothing seems to happen on a repeat run. That is often correct: with /D or /M, unchanged files are skipped. Remove the switch for one run to confirm files copy at all.

Prompts interrupt an unattended script. Add /Y to assume yes on overwrites, or /-Y to always prompt. Remember that /Y overwrites without asking.

Partial copy with errors listed. Re-run with /F and /C to see exactly which files failed, then handle those individually. Common causes are locks, permissions, and path length.

If that did not work, run xcopy /? to confirm the switch exists in your build, check the destination's free space, and try robocopy with the same paths as a comparison. Do not delete anything at the source until the destination has been verified.

Frequently Asked Questions

Does xcopy still work in Windows 11?

Yes. xcopy is included in Windows 11 and works from Command Prompt and Windows Terminal. Microsoft recommends robocopy for complex or very large jobs, but xcopy remains available and functional.

What is the difference between /S and /E?

/S copies subdirectories but skips empty ones. /E copies subdirectories including empty ones. Use /E when the folder structure itself matters.

How do I copy only newer files?

Add /D to copy only files whose source timestamp is newer than the destination copy. Combine with /S or /E to include subfolders.

Can xcopy delete files in the destination?

Only with specific deletion switches, and you should avoid them unless you fully understand the effect. For a true mirror that removes extra destination files, use robocopy with /MIR and test it on a scratch folder first.

Why does xcopy skip hidden files?

By default it does not copy hidden or system files. Add /H to include them.

Is xcopy better than drag-and-drop in File Explorer?

Not always, but it is better for repeatable, scriptable jobs, filtering by pattern or date, and preserving an exact folder structure. For one-off copies of a few files, File Explorer is simpler.