CMD Master
Back to Blog
UpdatedArnošt Havelka

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 Lesson
How to Copy a File in CMD with copy

cmd 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 the command

Try copying a file!

Build the command
copy
sourceThe file you want to copy.
destinationWhere you want the copy to go (directory or new filename).
Terminal
C:\Users\Student>copy file.txt backup.txt
1 file(s) copied.

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).

Terminal
C:\Users\Student>copy report.docx report_backup.docx

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:

Terminal
C:\Users\Student>copy *.txt backup\

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 / 2

What happens if the destination file already exists?

References

These documentation links provide authoritative details for the commands used in this article.

Up Next

Command Chaining with &&

Run dependent commands in sequence so the next step executes only when the previous one succeeds.