How to Copy a File in CMD with copy
Copy a file or a wildcard set in Command Prompt. Learn copy vs xcopy, overwrite prompts, and the /y switch.
Start Interactive Lessoncmd copy is the everyday job: duplicate report.txt, back up a file, or copy every *.jpg into another folder. The built-in command is copy. It copies files, not a whole directory tree. Official options are on Microsoft Learn: copy. Practice in the copy lesson.
Try copying a file!
How copy works
copy source destination writes a new file. Destination can be a new name or a folder. Success prints 1 file(s) copied. (or more for wildcards).
If the destination file already exists, cmd asks before overwrite. /y skips that prompt. /-y forces the prompt. /v verifies the write.
Wildcards copy a set of files:
copy does not move files. Moving is move. Creating a file from the keyboard is copy con.
When to use xcopy instead
Use xcopy when you need folders, empty subfolders, or a tree (/s, /e). copy on a directory name is the wrong tool and is a common reason backups look empty.
xcopy is still present on current Windows. For huge trees and restartable jobs, administrators often graduate to robocopy. For one file or *.txt in the current folder, stay with copy.
Common mistake
Pointing copy at a folder and expecting the whole tree. Use xcopy source dest /s (or /e) for directories.
FAQ
How do I copy a file in Command Prompt?
copy original.txt backup.txt
What is the difference between copy and xcopy?
copy is files (and wildcards). xcopy copies directory trees.
Can copy move files between folders?
No. That is move. copy leaves the original in place.
How do I copy an entire folder?
Use xcopy, not copy.
Is xcopy still available? Yes, on current Windows. See the xcopy guide.
Knowledge Check
1 / 2What happens if the destination file already exists?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Run dependent commands in sequence so the next step executes only when the previous one succeeds.