PowerShell: Rename a Folder

Need to rename a folder - fixing a typo, reorganizing a directory structure, or renaming as part of a script? This one-liner renames it directly from the terminal.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Rename-Item -Path "C:\OldFolderName" -NewName "NewFolderName"
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Rename-Item renames the item at the specified path - it works on files and folders alike.
  • -Path "C:\OldFolderName" points to the folder you want to rename - replace this with whatever path you actually want.
  • -NewName "NewFolderName" sets the new name for the folder - this is just the name itself, not a full path.