The Windows COPY command duplicates one or more files from Command Prompt. When you are already in a terminal — staging builds, backing up configs, or moving samples into a project — it is faster than opening File Explorer and dragging files around.
This guide covers the basics, wildcards, overwrite behavior, useful patterns, and common mistakes. For the official reference, see Microsoft Learn’s copy command.
What does COPY do?
copy notes.txt backup\
That copies notes.txt from the current directory into the backup folder. You can also name the destination file explicitly:
copy notes.txt backup\notes-old.txt
Relative paths resolve from where you are now. Confirm that with cd before you copy anything important.
Copy into a folder vs rename on copy
If the destination ends with a backslash (or is an existing folder), COPY keeps the original filename:
copy report.csv archive\
If the destination is a file path, COPY creates (or overwrites) that exact name:
copy report.csv archive\report-2026-09-14.csv
Wildcards for batches
Asterisks and question marks let you copy groups of files in one shot:
copy *.txt docs\
copy data?.csv staging\
*.txt grabs every text file in the current directory. data?.csv matches single-character wildcards like data1.csv and dataA.csv.
Overwrite prompts and quiet mode
When the destination file already exists, CMD usually asks before replacing it. To force overwrite without a prompt (handy in scripts):
copy /Y source.txt dest\source.txt
To always get a prompt even in batch files:
copy /-Y source.txt dest\source.txt
/Y is the flag you want for unattended .bat jobs. Leave the default interactive prompt when you are copying by hand and might overwrite something you care about.
Useful workflows
Backup a config next to the original
copy app.config app.config.bak
Stage build outputs into a release folder
copy bin\Release\*.dll release\lib\
Copy then verify the destination
copy readme.md docs\ && dir docs\readme.md
&& runs dir only if the copy succeeds.
Copy from another drive without changing directory
copy D:\usb\keys.env C:\projects\app\.env
COPY vs File Explorer
| Need | Why COPY helps |
|---|---|
| Exact names | No accidental drag-and-drop into the wrong folder |
| Scripts / automation | Repeatable file staging in a .bat file |
| Already in a prompt | No context switch to Explorer |
| Wildcards | One command moves a whole pattern of files |
Common mistakes
Destination folder missing
COPY does not create the destination folder for you. If backup does not exist, create it first:
mkdir backup
copy notes.txt backup\
Copying a folder tree
copy works on files, not whole directory trees. For recursive folder copies, use xcopy or robocopy instead. Start with single files and wildcards here; graduate to those tools when you need deep trees.
Wrong current directory
Relative sources always resolve from the current directory. If the file “isn’t found,” check where you are:
cd
dir
Then retry with a full path if needed:
copy C:\Users\Public\notes.txt D:\backups\
Overwriting without noticing
In scripts, forgotten /Y can hang on a prompt. In interactive use, an accidental /Y can silently replace a file. Match the flag to the situation.
Quick reference
| Goal | Command |
|---|---|
| File into a folder | copy file.txt dest\ |
| Rename on copy | copy file.txt dest\new.txt |
| All matching files | copy *.log logs\ |
| Force overwrite | copy /Y a.txt b.txt |
| Prompt before overwrite | copy /-Y a.txt b.txt |
| Copy then check | copy a.txt b\ && dir b\a.txt |
Practice COPY hands-on
Typing the command a few times sticks better than reading about it.
CMD Master is a free online interactive learning platform for the command line. Practice Windows CMD, PowerShell, and Bash in a live browser terminal with instant feedback — no install and no VM. Most lessons are free. For a structured Windows path that covers core commands like COPY, start the interactive Windows Command Prompt course.
Tip: run copy /? in a real prompt once, then practice a /Y backup copy until the overwrite behavior feels obvious.
Top comments (0)