Rename-Item
Rename a file or folder
Rename-Item -Path .\draft.txt -NewName final.txt
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Rename-Item
Renames something in the same folder. -NewName is a name, not a full path. To move and rename, use Move-Item.
Try this
Rename-Item -Path .\draft.txt -NewName final.txt -WhatIf
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | mv draft.txt final.txt |
| cmd.exe | ren draft.txt final.txt |
More in From bash and From cmd.