Files

Bulk Rename Files with PowerShell

3 min · updated June 14, 2026

Rename-Item with a script-block -NewName renames in bulk. Preview first with -WhatIf.

Change the extension (.jpeg → .jpg)

Get-ChildItem *.jpeg | Rename-Item -NewName { $_.Name -replace '\.jpeg$', '.jpg' }

Add a prefix to every file

Get-ChildItem *.pdf | Rename-Item -NewName { "2026_" + $_.Name }

Replace text in filenames

Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace ' ', '_' }   # spaces -> underscores

Lower-case all filenames

Get-ChildItem | Rename-Item -NewName { $_.Name.ToLower() }

Number files sequentially (001, 002, …)

$i = 1
Get-ChildItem *.jpg | Sort-Object Name | ForEach-Object {
  Rename-Item $_ -NewName ("photo_{0:D3}{1}" -f $i++, $_.Extension)
}

Preview before you commit

Get-ChildItem *.jpeg | Rename-Item -NewName { $_.Name -replace '\.jpeg$', '.jpg' } -WhatIf

Always run with -WhatIf first — it prints what would be renamed without changing anything. -replace uses regex, so escape special characters (\. for a literal dot). Renames that would collide (two files mapping to the same name) will error — fix the pattern or add a counter.

← All recipes