•Arnošt Havelka
Moving and Renaming Files
Use mv to move files between directories and rename them.
Start Interactive LessonMoving and Renaming Files
The 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.
Usage:mvoldnamenewname
mv
Move or rename - relocates or renames files and directories.
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.
Usage:mvfile.txtdirectory/
directory/
Target directory - relocates file to the specified folder.
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.
Usage:mvfile.txtdirectory/newname.txt
directory/newname
Full path with new name - moves and renames in one step.
Two operations at once:
Command Prompt
draft.txt
C:\Users\User>ls
Knowledge Check
1 / 3What does mv do?
References
These Microsoft Learn and Windows documentation links provide authoritative details for the commands used in this article.