How to Batch Rename Files in Windows 10 and 11 Safely

Batch rename files in Windows and a folder called IMG_0021, IMG_0022 and IMG_0023 becomes Holiday_01, Holiday_02 and Holiday_03 in one move. Most people never need a script for this, because File Explorer has a rename box that does more than it first appears to. This guide starts with the Explorer route, covers the wildcards and the search trick that handles a whole folder, then moves into PowerShell and Command Prompt where you can rename by any rule you can describe. It finishes with the safety rules and the mistakes that quietly ruin a batch.

Rename in File Explorer with the F2 key

Open the folder and select the files. Ctrl and click picks individual files, Shift and click picks everything between the first and the last one, and Ctrl and A selects all of them. With the files selected press F2, and the name of one of them appears in a box with the extension highlighted.

Type the new name and press Enter. Windows applies it to every selected file and keeps each one's extension, so a group of IMG_0021.jpg, IMG_0022.jpg and IMG_0023.jpg becomes Holiday (1).jpg, Holiday (2).jpg and Holiday (3).jpg.

If a file with the new name already exists, Windows neither asks nor overwrites. It adds a number in brackets before the extension, so the third Holiday photo becomes Holiday (3).jpg. That numbering is the safety net you want on a large batch.

Use the asterisk and question mark in the rename box

The rename box understands two wildcards and they do different jobs. The asterisk stands for a number, and the question mark stands for a single character.

Use the asterisk when you want a sequence. Type Photo (*).jpg and Explorer names the files Photo (1).jpg, Photo (2).jpg and so on, counting up as it goes. Use two of them, Photo (*).(*).jpg, and the second counts separately, which is handy when the files already carry a date or a counter in the name.

The question mark behaves differently. On a single file, Explorer fills it from its own character sequence, so chapter?.txt becomes chaptera.txt and then chapterb.txt as you keep renaming. With several files selected the question mark is filled with numbers alongside the asterisk, so try it on two files before you run it across a folder.

A rename input field with a pattern typed into it before confirming
The rename box is where the pattern goes. What you type decides what the files become.

Search first, then rename everything that matches

The most reliable way to rename a whole set is to find it with a search first. Open the folder, click the search box in the top right corner and type *.jpg. Windows filters the view down to the JPEG files and ignores everything else.

Switch the view to Details using the View button in the ribbon, press Ctrl and A to select everything shown, then press F2 and type the new name. Because the search already narrowed the list, the pattern cannot catch a stray document or a subfolder by accident.

This is the method I use when the folder holds mixed content, such as a Downloads folder holding receipts, invoices and photos. Our guide to taking screenshots on Windows 10 and 11 covers naming those files properly in the first place, which saves a rename later on.

Do it in PowerShell when you need real control

PowerShell is where the real control sits, because you can describe the rule instead of clicking through a dialog. Open Windows Terminal or Windows PowerShell from the Start menu, and you do not need administrator rights for your own folders. Rename-Item changes the name in place, it does not move a file to another folder.

To strip the digits out of every JPEG name, run this:

Get-ChildItem -Path C:\Photos -Filter *.jpg | Rename-Item -NewName { $_.Name -replace '\d+', '' }

The script block is the part that matters. It receives each file as $_ and produces the new name, so $_.Name -replace '\d+', '' removes the digits and keeps the extension. Watch for two traps: two files that reduce to the same name collide and the second rename fails, and a file named 2024.jpg ends up called .jpg.

To add a prefix instead, use this:

Get-ChildItem -Path C:\Photos -Filter *.jpg | Rename-Item -NewName { '2026_' + $_.Name }

To number the files in a clean sequence, use a counter in a ForEach-Object loop:

$i = 0
Get-ChildItem -Path C:\Photos -Filter *.jpg | ForEach-Object {
  $i++
  Rename-Item -Path $_.FullName -NewName ("photo_{0:D3}.jpg" -f $i)
}

The D3 format writes 001, 002 and 003, which sorts properly in File Explorer. To change the extension on a set of files in bulk, work from the base name:

Get-ChildItem -Path C:\Photos -Filter *.png | Rename-Item -NewName { $_.BaseName + '.jpg' }

That last one only changes the letters at the end of the name. It does not convert the picture data, so a PNG file renamed to .jpg still holds a PNG image and some programs complain about the mismatch.

A terminal window running a PowerShell rename script over a folder of files
One line of PowerShell applies the same rule to every file the filter matches.

The Command Prompt loop for a whole folder

Command Prompt has a for loop that renames a folder in one line. Run it from inside the folder you want to change:

for %i in (*.jpg) do ren "%i" "photo_%~ni.jpg"

The %i is the current file, and %~ni expands to the file name without its extension, so IMG_0021.jpg becomes photo_IMG_0021.jpg.

One percent sign is right when you type the command straight into Command Prompt. Inside a batch file you double them, because a batch file reads % as a variable marker:

for %%i in (*.jpg) do ren "%%i" "photo_%%~ni.jpg"

Save that as a .bat file and not a .txt, then run it from the folder. Put the single percent version into a batch file and the loop does nothing useful at all.

Rules that keep a rename reversible

A rename cannot be undone from Explorer, so treat a batch as a one way door until you have checked it. Copy the folder to a working copy, run the rename there, and only then run it on the real thing. If the folder holds anything you cannot replace, our guide to backing up important files on Windows is the place to start.

Do not depend on the order Explorer shows you. Sorting changes when a file is added, and a rule built on position then picks the wrong file. Build the rule on the name itself instead.

Keep the full path under 260 characters, which is the Windows limit, and the file name itself under 255 characters. Go over and Windows refuses with The file name or path you entered is too long.

Decide what happens to the extension before you start. Explorer keeps it for you, the ren command in Command Prompt does not, and PowerShell takes whatever your script block returns.

If the files arrived inside a zip archive, our guide to fixing Windows zip extraction errors covers getting them out cleanly first.

What goes wrong most often

The most expensive mistake is a pattern that matches more than you meant. A filter of *.docx catches every Word file in the folder, including the contract you had no intention of touching. Check the count in the search results before you press F2.

The second is a lost extension. Type holiday without .jpg in the Command Prompt loop and the file is called holiday with no extension at all, so Windows no longer knows which program opens it.

The third is renaming a file that a program is holding open. Word, a photo editor or a sync client keeps a lock, and the rename fails with a message about the file being in use. Close the program and try again.

The fourth is a name collision. Two files cannot share one name in a folder, so the second rename fails. Explorer dodges this with the (2) numbering, and PowerShell and Command Prompt do not.

A fifth is working on the wrong folder altogether, often a copy of a copy. When you are hunting for the biggest offenders on a drive, our guide to finding large files taking up disk space shows how to confirm you are in the right place before you start.

Two columns of file names showing the names before and after a batch rename
Comparing the old names with the new ones before you commit to the change.

Tools with a preview and an undo

PowerRename, the file renaming tool in Microsoft PowerToys, shows the old name and the new name side by side before anything moves, and it keeps a record you can undo. It also handles regular expressions, which is how you rename a folder by capturing part of the old name.

Bulk Rename Utility is a small standalone free program that does the same job with filters, numbering and a preview pane. Neither is necessary for a simple folder, and both earn their place when there are thousands of files.

Frequently asked questions

How do I rename multiple files at once in Windows?

Select the files in File Explorer with Ctrl or Shift, press F2, type the new name and press Enter. Windows numbers the result and keeps the extension.

What does the asterisk do in a Windows rename box?

It marks the spot where the number goes. Explorer replaces it with a number per file, so Photo (*).jpg becomes Photo (1).jpg, Photo (2).jpg and so on.

How do I rename every JPG in a folder at once?

Search the folder for *.jpg, switch the view to Details, select everything with Ctrl+A, then press F2 and type the new name.

Why do some renamed files lose their extension?

The ren command in Command Prompt takes the whole name exactly as you type it, so a name without .jpg leaves a file with no extension.

Can I undo a batch rename in Windows?

Explorer has no undo for renaming. A preview tool such as PowerRename shows the old name next to the new one and can put them back, so work on a copy first.

What to remember

Try the Explorer route on a folder of ten files you do not mind losing, watch what it does with the numbers, and only then point it at the folder that matters. When you do need a rule that Explorer cannot express, start in PowerShell with Get-ChildItem and a script block.