How to Copy Files Using Command Prompt in Windows 10 (copy, xcopy, robocopy)

Copying files with Command Prompt is faster than dragging and dropping when you need to copy many files at once, filter by file type, resume a large transfer, or script a regular backup. Windows 10 includes three copy commands: copy for individual files, xcopy for folders, and robocopy, the most powerful, for large or repeated jobs. This guide explains each with ready-to-use examples.

Quick Answer

To copy one file: copy “C:\source\file.txt” “D:\destination\”. To copy a whole folder, including subfolders: robocopy “C:\source” “D:\destination” /E. Put paths in quotation marks if they contain spaces.

Command Prompt showing a copy command copying one file and a robocopy command copying a folder with its summary table
copy (1) handles single files. robocopy (2) copies whole folders and shows a summary of what it copied.

Open Command Prompt

  1. Press Windows + R, type cmd, and press Enter.
  2. To copy into protected folders like C:\Program Files, search for cmd in Start, right-click Command Prompt, and choose Run as administrator.

Tip: Type cd followed by a folder path to move into that folder, so you can use shorter file names. Drag a file or folder from File Explorer into the Command Prompt window to paste its full path.

Which Command to Use

Command Best for Copies subfolders?
copy One or a few files, combining files No
xcopy Folders, simple jobs (older tool) Yes, with /S or /E
robocopy Large folders, backups, network copies, resuming Yes, with /E

1. The copy Command

  • Copy a file to another folder:
    copy C:\Users\Alex\Documents\report.docx D:\Backup\
  • Copy and rename:
    copy report.docx D:\Backup\report-old.docx
  • Copy all files of one type (wildcard):
    copy C:\Photos\*.jpg E:\Photos\
  • Paths with spaces need quotes:
    copy “C:\My Files\Budget 2026.xlsx” “E:\Backup\”
  • Overwrite without asking: add /Y, as in copy /Y file.txt D:\Backup\.

If the destination folder doesn’t exist, create it first with mkdir D:\Backup, or copy will treat the name as a file.

2. The xcopy Command

xcopy copies folders and their contents:

xcopy “C:\Projects” “D:\Backup\Projects” /E /I /H /Y

  • /E copies all subfolders, including empty ones.
  • /I assumes the destination is a folder (avoids the “file or directory?” prompt).
  • /H includes hidden and system files.
  • /Y overwrites existing files without asking.
  • /D copies only files newer than the ones already in the destination.

xcopy still works, but Microsoft recommends robocopy for anything complex.

3. The robocopy Command (Recommended for Folders)

Basic folder copy with all subfolders:

robocopy “C:\Users\Alex\Pictures” “E:\Backup\Pictures” /E

Useful options:

  • /E copies subfolders, including empty ones.
  • /Z restartable mode: resumes large files if the connection drops (great for network and USB drives).
  • /R:2 /W:5 retries a failed file 2 times, waiting 5 seconds. The default is 1 million retries with 30-second waits, which can look like a freeze.
  • /MT:16 copies with 16 threads for speed on many small files.
  • /XF *.tmp excludes files by pattern; /XD “folder” excludes folders.
  • /LOG:C:\copylog.txt saves a log of the copy.
  • /COPY:DAT copies data, attributes, and timestamps (the default).

Be careful with /MIR. It mirrors the source, which means it deletes files in the destination that aren’t in the source. It’s ideal for keeping an exact backup in sync, but pointing it at the wrong destination folder can erase files. Test with /L (list only, no changes) first.

Robocopy doesn’t say “done” like copy; check the summary table. Exit codes 0 to 7 mean success; 8 or higher means some files failed.

Copy From or To a Network Share or USB Drive

  • USB drive: use its drive letter, as in robocopy C:\Data E:\Data /E /Z.
  • Network share: use the UNC path, as in robocopy C:\Data “\\NAS\Backups\Data” /E /Z.

Automate It With a Batch File

  1. Open Notepad and type your command, for example robocopy “C:\Users\Alex\Documents” “E:\Backup\Documents” /E /Z /R:2 /W:5.
  2. Save it as backup.bat (choose All files as the file type).
  3. Double-click it to run, or schedule it in Task Scheduler with Create Basic Task.

PowerShell Alternative

In PowerShell, use Copy-Item: Copy-Item “C:\Source\*” “D:\Dest” -Recurse. Robocopy also works in PowerShell and Windows Terminal.

Troubleshooting

  • “The system cannot find the file specified”: Check the path and use quotes around names with spaces.
  • “Access is denied”: Run Command Prompt as administrator, or make sure the file isn’t open in another program.
  • “The syntax of the command is incorrect”: Usually a missing quote or a trailing backslash inside quotes with robocopy (use “C:\Folder” not “C:\Folder\”).
  • Copy looks stuck: robocopy may be retrying a locked file. Add /R:2 /W:5.

Summary

  1. One file: copy “source” “destination”.
  2. Folders: robocopy “source” “destination” /E.
  3. Add /Z, /R:2 /W:5, and /MT for big or network copies.
  4. Use /MIR only when you want an exact mirror, and test with /L first.