How to copy files
Overview
copy duplicates files to another filename or folder. The source stays in place.
Confirm the source and destination before copying. When destination names collide, CMD may prompt or replace data depending on options and context.
- A trailing backslash helps show that the destination is a folder.
- Create the destination folder first with
mkdir. - Use
robocopyfor reliable folder trees and repeatable backups.
Commands to try
Type each command at the prompt, then press Enter. Replace sample names and paths with ones that exist on your computer.
Commands are generally not case-sensitive, but preserving the spelling shown here makes scripts easier to read.
copy notes.txt notes-backup.txt
copy *.txt Backup\
copy /-y report.txt "D:\Archive\report.txt"
copy /b part1.bin+part2.bin combined.bin
Useful options and details
Options change how a command behaves. Add spaces exactly as shown, and use the command's built-in help when an option is unfamiliar.
A path containing spaces must be enclosed in double quotes, such as "C:\My Files".
/-yprompts before replacing an existing file;/ysuppresses prompts./vverifies that new files can be read./buses binary mode and is appropriate when combining binary parts.
Tips and common mistakes
Check the current folder and read the command output before assuming an operation succeeded.
Practice with disposable files first. Commands that delete, overwrite, or stop a process may not offer an Undo button.
- Do not assume copying a folder name copies all of its contents; use
robocopyfor folders. - Wildcards can match more files than expected, so preview them with
dir. - A successful copy is not a backup until you verify the destination.
Safe practice
Create a temporary practice folder under your user profile so the examples cannot affect Windows system files.
After each command, inspect the result with dir or another read-only command before continuing.
- Copy one practice text file under a new name.
- Create a Backup folder and copy all practice text files.
- Compare both locations with
dir.