PowerShell Genie

Rename-Item

Use Rename-Item to rename a file, folder, or registry key — and to bulk-rename hundreds of files in one pipeline.

Command 3 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — rename-item

Syntax

1PS> Rename-Item [-Path] <String> [-NewName] <String> [-Force] [-PassThru] [-Credential <PSCredential>] [<CommonParameters>]

Try it

Windows PowerShell

PowerShell example · browser support is limited.

Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

Interactive simulation · fictional data

Examples

Rename a single file

1PS> Rename-Item -Path .\old-report.txt -NewName new-report.txt
Show reference output

Illustrative output · values vary by environment

(no output; the file is now new-report.txt)

Bulk-rename files by replacing part of the name

1PS> Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace 'draft', 'final' }
Show reference output

Illustrative output · values vary by environment

(draft-report.txt becomes final-report.txt, and so on)

Rename and confirm what changed

1PS> Rename-Item -Path .\notes.txt -NewName archive.txt -PassThru
Show reference output

Illustrative output · values vary by environment

Directory: C:\Docs
Mode  LastWriteTime  Length  Name
----  -------------  ------  ----
-a---  2026-10-24     512    archive.txt

Parameters

Parameter definitions:

  • -Path — The item to rename. Accepts wildcards.
  • -NewName — The new name only — not a full path. To move and rename, use Move-Item instead.
  • -Force — Renames read-only or hidden items, and overwrites an existing item with the same name.
  • -PassThru — Returns the renamed item so you can confirm or pipe it onward.

Microsoft Learn — rename-item

NewName is a name, not a path

The most common Rename-Item error is passing a full path to -NewName. It accepts only the new name itself: -NewName 'report.txt', never -NewName 'C:\Docs\report.txt'. To change the folder as well, use Move-Item, which renames and moves in one step.

For bulk renames, pipe Get-ChildItem into Rename-Item with a script block for -NewName. Inside the block, $_ is the current file, so $_.Name -replace 'old','new' renames every file by the same rule. Always run with -WhatIf first to preview a bulk rename.

A rename fails if the file is open in another program or the destination name already exists. Close the file first, or add -Force to overwrite the destination.

Move and rename with Move-Item

List files to rename with Get-ChildItem

Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.

Recap

Rename-Item Use Rename-Item to rename a file, folder, or registry key — and to bulk-rename hundreds of files in one pipeline.

Next: New Localuser
Genie guideRename-Item

Rename-Item renames a single item or a whole folder of files at once. Learn the one mistake everyone makes (NewName is a name, not a path), the bulk-rename pipeline pattern, and how to force a rename over a locked file. The console below is pre-loaded — run it, then change a value and run it again.