copy, move and ren: copy, move and rename files
These commands do from the keyboard what dragging does in File Explorer. They are quick for single files and far quicker than the mouse for groups of files chosen by a pattern, such as "every .txt file".
copy
copy takes a source and a destination.
C:\Users\asha\demo>copy notes.txt notes-backup.txt
1 file(s) copied.
C:\Users\asha\demo>copy notes.txt old
1 file(s) copied.
C:\Users\asha\demo>dir /b old
draft.txt
notes.txtThe first command made a copy under a new name in the same folder. The second put a copy into the folder old, keeping the name.
Wildcards copy several files at once.
C:\Users\asha\demo>mkdir backup
C:\Users\asha\demo>copy *.txt backup
log.txt
notes-backup.txt
notes.txt
report.txt
4 file(s) copied.Danger. If a file of the same name is already at the destination, copy asks before replacing it when you type the command yourself, but not when the command runs inside a batch file, and not if you add /y. Replacing a file destroys the old one. There is no Recycle Bin for this.
What copy cannot do
copy handles files, not folders. Given a folder name as the source, it copies the files directly inside and ignores subfolders. For whole folders, use xcopy or robocopy.
xcopy: folders and all
C:\Users\asha\demo>xcopy photos photos-copy /e /i
photos\beach.jpg
photos\hills.jpg
2 File(s) copied
C:\Users\asha\demo>dir /s /b photos-copy
C:\Users\asha\demo\photos-copy\beach.jpg
C:\Users\asha\demo\photos-copy\hills.jpg/ecopies all subfolders, including empty ones./itells xcopy that the destination is a folder, so that it does not stop to ask.
Other useful switches: /d copies only files newer than those already at the destination, /h includes hidden files, and /y stops it asking before overwriting.
robocopy: for serious copying
robocopy, short for robust copy, is the tool for backups and large folders. It can resume after an interruption, copy only what has changed, and write a log.
robocopy C:\Users\asha\Documents D:\Backup\Documents /eThe order is source folder, destination folder, then options. /e includes subfolders. Run again later, it copies only new and changed files.
Danger. robocopy /mir makes the destination an exact mirror of the source. That means it also deletes from the destination anything that is not in the source. Pointed at the wrong folder, it can empty it. Add /l first: that lists what would happen without doing anything.
move
move takes a file from one place and puts it in another. The original is gone from where it was.
C:\Users\asha\demo>move report.txt old
1 file(s) moved.
C:\Users\asha\demo>dir /b old
draft.txt
notes.txt
report.txtGiving a new name at the destination moves and renames in one step. move also renames folders.
C:\Users\asha\demo>move old archive
1 dir(s) moved.
C:\Users\asha\demo>dir /ad /b
archive
backup
photos
photos-copyLike copy, move asks before overwriting when typed by hand, and /y suppresses the question.
ren: rename
C:\Users\asha\demo>ren notes.txt todo.txt
C:\Users\asha\demo>dir /b *.txt
log.txt
notes-backup.txt
todo.txtren changes the name only. It cannot move a file to another folder, so the new name must not include a path.
Wildcards rename in bulk. This changes the ending of every .txt file to .bak:
C:\Users\asha\demo>ren *.txt *.bak
C:\Users\asha\demo>dir /b
archive
backup
log.bak
marks.csv
notes-backup.bak
photos
photos-copy
todo.bakChanging a file's ending does not change what is inside it. A text file renamed to .jpg is still text, and will not open as a picture.
Names with spaces
Any name containing a space needs double quotation marks, or the command treats it as two names: copy "annual report.txt" backup.
Checking before a bulk change
Before copying, moving or renaming with a wildcard, run dir with the same pattern. It shows exactly which files the pattern matches.
C:\Users\asha\demo>dir /b *.bak
log.bak
notes-backup.bak
todo.bakSummary
| Job | Command |
|---|---|
| copy a file | copy source destination |
| copy a folder with its contents | xcopy source destination /e /i |
| back up or synchronise a folder | robocopy source destination /e |
| move a file or folder | move source destination |
| rename | ren oldname newname |
On Linux and the Mac, see cp and mv.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.