mv Move or rename files and directories
Moves a file or folder to another place, or renames it when the target is in the same folder. The original name no longer exists afterwards. Unlike cp, it does not need a flag to handle folders.
Synopsis
mv [OPTION]... SOURCE TARGET
mv [OPTION]... SOURCE... DIRECTORY
Common options
| Option or form | What it does |
|---|---|
-i | Interactive: ask before overwriting an existing file |
-n | Do not overwrite an existing file |
-f | Force: overwrite without asking, even if the target is write-protected |
-v | Verbose: print each file as it is moved |
-h | BSD and macOS: if the target is a symbolic link to a folder, do not follow it |
Examples
mv notes.txt ideas.txt
mv app.log docs
mv -v photos/a.jpg photos/b.jpg docs
mv photos pictures
mv -n data.csv docs/data.csv
mv -i draft.docx final.docx
Notes
- mv replaces an existing target without asking. There is no undo. Use -i when you are unsure, or -n to protect existing files.
- Renaming and moving are the same operation. mv a b renames a if b does not exist, and moves a into b if b is an existing folder.
- Within one disk a move is instant, because only the name changes. Across disks it copies and then deletes, so it takes longer and can leave partial results if interrupted.
- There is no built-in way to rename many files at once. Use a shell loop, for example for f in *.txt; do mv "$f" "${f%.txt}.md"; done.
- The -h, -n and -v options are non-standard, according to the macOS man page, so avoid them in scripts that must run on every system.
See also
Last reviewed 2026-10-07.