Rename Hundreds of Files at Once with PowerShell

Rename Hundreds of Files at Once with PowerShell

📎 This article includes 2 downloadable practice files ↓

⏱ 2 min readUpdated 27 September 2026

PowerShell is built into Windows and is perfect for file chores. Open it from the Start menu (type “PowerShell”) and cd into your folder, e.g. cd "C:\Reports\March".

In this article
  1. Always preview first
  2. 1. Replace text in file names
  3. 2. Add today’s date to every file
  4. 3. Number files in order
  5. 4. Clean messy names (spaces, brackets)
  6. 5. Include sub-folders
  7. Try it yourself: step by step

Always preview first

Every example below uses -WhatIf, which shows what would happen without changing anything. Remove it when the preview looks right.

1. Replace text in file names

Get-ChildItem *.xlsx | Rename-Item -NewName { $_.Name -replace "Draft", "Final" } -WhatIf

2. Add today’s date to every file

$d = Get-Date -Format "yyyy-MM-dd"
Get-ChildItem *.pdf | Rename-Item -NewName { "$($_.BaseName)_$d$($_.Extension)" } -WhatIf

3. Number files in order

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

{0:D3} pads numbers to three digits (001, 002…), so they sort correctly.

4. Clean messy names (spaces, brackets)

Get-ChildItem | Rename-Item -NewName { ($_.Name -replace "[\(\)\[\]]", "" -replace "\s+", "_") } -WhatIf

5. Include sub-folders

Add -Recurse to Get-ChildItem. Be extra careful and keep -WhatIf until you are sure.

⚠️ There is no Undo for renames. Copy the folder first, or log the old and new names: Get-ChildItem | Select-Object Name, @{n="New";e={$_.Name -replace "Draft","Final"}} | Export-Csv rename-log.csv.

Prefer clicking to typing? The same job in Power Automate Desktop.

Try it yourself: step by step

  1. Download rename-practice.zip and unzip it — you get eight files like Report Draft (1) v2.txt.
  2. Shift + right-click inside the folder → Open PowerShell window here (or Terminal).
  3. Paste the first command from rename-examples.ps1. Because of -WhatIf it only prints “What if: Performing the operation Rename File…”.
  4. Remove -WhatIf and run it for real — “Draft” becomes “Final”.
  5. Run the “clean messy names” command: brackets vanish and spaces become underscores.

📎 Practice files for this article

  • 🗂️
    8 messy practice files (zip)Names with spaces, brackets and 'Draft' u2014 safe to experiment on.
    ⬇ ZIP · 1 KB
  • 🖥️
    PowerShell examples (.ps1)Every command from the article, with -WhatIf preview.
    ⬇ PS1 · 418 B

Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.