•Arnošt Havelka
Moving and Renaming Files
Use mv to move files between directories and rename them.
Start Interactive LessonThe mv command moves and renames files. It's faster than copy-then-delete because it doesn't duplicate data.
Rename a File
Use mv oldname newname to rename a file in the same directory.
Try the command
Rename a file!
Build the command
mvoldnamenewname
Choose a command
Terminal
C:\Users\User>mv old.txt new.txt
Change a name:
Command Prompt
draft.txt
C:\Users\User>ls
Move to Another Directory
Use mv file directory/ to move a file to a different folder.
Try the command
Move file to another folder!
Build the command
mvfile.txtdirectory/
Choose a command
Terminal
C:\Users\User>mv file.txt ~/Documents/
Relocate a file:
Command Prompt
file.txt
Archive/
ls Archive/
C:\Users\User>ls
Move and Rename Together
Combine both operations by specifying the full path with a new name.
Try the command
Move and rename together!
Build the command
mvfile.txtdirectory/newname.txt
Terminal
C:\Users\User>mv old.txt ~/Archive/new.txt
Two operations at once:
Command Prompt
draft.txt
C:\Users\User>ls
Knowledge Check
1 / 3What does mv do?
References
These documentation links provide authoritative details for the commands used in this article.
Up Next
Removing Files and Directories
Learn rm and rmdir to delete files and directories safely.