copy command (Windows / CMD)
What it does
Copy one or more files and optionally combine text or binary files. Searches for the copy command cmd usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Copy one or more files and optionally combine text or binary files.
Syntax
copy [/D] [/V] [/N] [/Y | /-Y] source [destination]
Common options
| Flag / option | Meaning |
|---|---|
| /Y | Suppress overwrite confirmation. |
| /-Y | Prompt before replacing a destination. |
| /V | Verify that new files can be read. |
| /B | Treat the selected file as binary. |
Practical examples
Copy file
copy report.txt D:\Archive\
Copies a file into Archive.
Confirm overwrite
copy /-Y config.ini config.bak
Prompts if config.bak exists.
Combine text
copy /A part1.txt+part2.txt complete.txt
Concatenates two text files.
Linux ↔ Windows equivalent
Closest match: cp (Linux / bash / sh / zsh). Copy files or directory trees to another location.
Common mistakes
- Using copy for directory trees; use xcopy or robocopy.
- Reversing source and destination and replacing the wrong file.
Related commands
- xcopyCopy files and directory trees with filtering and overwrite controls.
- robocopyReliably copy and synchronize large directory trees.
- Copy-ItemCopy items between locations supported by PowerShell providers.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
FAQ
What does copy do in Command Prompt?
Copy one or more files and optionally combine text or binary files.
How do I run copy in CMD?
Open Command Prompt and follow `copy [/D] [/V] [/N] [/Y | /-Y] source [destination]`; quote paths containing spaces.
What is a practical copy example in CMD?
Try `copy report.txt D:\Archive\` — Copies a file into Archive.
Can copy be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.