Bulk Rename Files with Regular Expressions on Windows

Regular expressions let you rewrite many filenames with one pattern instead of editing each by hand. Here is when they help and which Windows tools support them.

Bulk Rename Utility screenshot showing a file list with three BRU_setup files renamed, beside RegEx, Replace and Remove panels.
In this article

You can bulk rename files with regular expressions on Windows by writing one pattern that describes how your file names look, then letting a tool apply it to every file at once. A regular expression is a pattern that matches parts of a name, such as everything between two words or a run of digits, so you are not limited to one fixed piece of text. Learn more in How to Preview Bulk File Rename Before Applying It.

That means a single rule can change hundreds of files, even when each file has a different name. Microsoft’s PowerRename, a PowerToys utility, is built for this: it renames many files at once and lets you perform a regular expression rename on multiple files. [1]

This article explains when a regex rule beats simple search and replace, how patterns and capture groups work, how to use them in PowerRename, and how to pick a renamer that supports them.

When is a regular expression better than simple search and replace?

A regular expression is better than simple search and replace when the part of the name you want to change isn’t a fixed string, or when the new name depends on pieces of the old one. If you only need to swap one exact word for another, plain search and replace is enough.

Targeting a section of the name

Search and replace works well when every file contains the same text, such as changing “foo” to “foobar”. PowerRename can do a search and replace on a targeted section of file names. [1] A pattern goes further: it can target a section that differs from file to file, like a run of digits or a date, where no single fixed string would match.

Matching a whole name pattern

A pattern can describe the shape of an entire name. For example, ^foo.*bar$ matches names that start with “foo” and end with “bar”, whatever sits between them. [1] That helps when a folder mixes several naming styles and you want to change only one of them.

Reordering or reusing parts of the old name

Patterns can also keep part of the old name in the new one. The replacement $1_foo.png reuses a piece of the original name and adds new text around it. [1] Likewise, $MMM-$DD-$YY-powertoys builds a date-style name. [1] Simple search and replace can’t move or reuse text like this, because it has no way to remember what it matched.

When you don’t need regex

Many common jobs don’t call for patterns at all. Free renamers list plain actions such as inserting text, numbering as a prefix or suffix, replacing, removing, changing case, and adding dates. [2] Regular expressions are one option among these, not a requirement. [2]

A rough rule: if you can describe the change as “replace this exact text” or “add a number,” use the simple option. If you find yourself saying “the part between,” “anything that starts with,” or “swap these two pieces,” a regular expression is the right tool.

How do match patterns and capture groups work?

A match pattern tells PowerRename which part of a name to find, and a capture group lets you keep part of that match and reuse it in the new name.

Anchors and wildcards

An anchor pins the pattern to the start or end of the name. A wildcard stands in for any characters in between. The pattern below, which PowerRename’s documentation uses as an example, matches names that start with “foo” and end with “bar”:

^foo.*bar$

Here ^ marks the start of the name, .* means any characters in any amount, and $ marks the end. So a name like “foo_holiday_bar” matches, but “my_foo_bar” does not, because it doesn’t begin with “foo”. [1]

Reusing a captured group

A group is a part of the pattern wrapped in parentheses. In the replacement field, $1 refers to whatever the first group matched. The documentation shows this replacement:

$1_foo.png

The new name starts with the text captured by the first group, then adds _foo.png. This is how you reorder or keep pieces of the old name instead of overwriting them. [1]

Date-style replacement

PowerRename also accepts date-style tokens in the replacement field. The documented example is:

$MMM-$DD-$YY-powertoys

The tokens $MMM, $DD and $YY are filled with date values, so each file gets a name that begins with a month, day and year followed by -powertoys. [1]

Start small and read the preview

Begin with one simple pattern on two or three files, not your whole folder. For example, try ^foo.*bar$ on a few test names and see which ones match. PowerRename shows the expected results in a preview pane before you finalize anything, so you can read each new name beside the old one and adjust the pattern until it looks right. [1]

Graphic titled "Brackets & Parentheses" showing three colored squares with parentheses, square brackets and curly braces.

How do you use regex in PowerRename?

Select your files in File Explorer, right-click, and choose Rename with PowerRename; the entry appears only if the utility is enabled in PowerToys. [1] The window lists the selected items, search and replace boxes, a list of options, and a preview pane. [1]

Basic steps

  1. Select the files in File Explorer.

  2. Right-click and choose Rename with PowerRename.

  3. Type your pattern in the search box and the new text in the replace box.

  4. Turn on regular expression matching in the options list.

  5. Read the preview pane, then apply the rename.

The preview shows the results of the search and replace values you entered, so adjust the pattern until the new names look right. [1]

Counters

PowerRename can number files in the replace field with these tokens:

${increment=X}
${padding=X}
${start=X}

increment sets the step between numbers, padding sets how many digits each number has, and start sets the first number. You can combine them in one token. For example:

Image_${padding=4;increment=2;start=10}_

This style of name begins at 10, counts by 2, and pads to four digits. [1]

Random values

For random text in a name, use one of these tokens:

${rstringalnum=X}
${rstringalpha=X}
${rstringdigit=X}
${ruuidv4}

They produce random letters and numbers, letters only, digits only, or a UUID, in that order. [1]

Safety

Renaming many files at once is hard to undo by hand, so back up important files and check the preview first. PowerRename also offers an undo after a rename is completed, and Explorer’s Undo Rename (Ctrl+Z) can reverse the last change. [1]

Versions

PowerToys works on Windows 10 and 11, and the steps are the same. Windows 10 is past end of support.

How do you choose a renamer that supports regex?

Pick a renamer that lets you type a regular expression into its search field, shows the result before you apply it, and can limit the job to certain file types. PowerRename covers all three, but other tools can work too.

What to look for

  • Regex support in the search field. PowerRename lets you perform a regular expression rename on multiple files. [1] Many basic batch renamers also let you rename files using regular expressions. [2]

  • A live preview. Look for a tool that displays the new name beside the original name so you can compare in real time. [2] PowerRename also has a preview pane that shows the results of your search and replace values. [1]

  • File type filters. Some renamers let you filter particular file types, so a rule meant for .jpg files does not touch your .docx files. [2]

  • Undo. PowerRename can undo a rename after it is completed. [1]

Other tools worth knowing

The Microsoft Store app called Bulk Rename supports regular expressions. [3] It also lets you set positions in a name using absolute indices or indices relative to a particular string or regular expression. [3] That is handy when you want to insert text right after a marker in the name rather than at a fixed character count. It also helps to read How to Rename Files Using Metadata in Windows.

Freeware roundups for Windows include renamers with regex options. Bulk Rename Utility is free for non-commercial use and has a RegEx option for renaming files with regular expressions. [2]

Avoid cracked downloads

Get renamers from the publisher or an official store, not from pages offering a “crack” or “license key.” Such pages advertise the same tool’s regex support, [4] but a tampered installer has no business touching your files. A free, legitimate option almost always exists, and PowerRename is one of them.

Common questions about regex renaming

Do I need to learn regex for every rename?

No. PowerRename handles plain search and replace on a targeted section of file names, so you only need a pattern when the job calls for one. [1] Numbering, inserting text, removing strings, replacing strings and changing case are all covered by the Bulk Rename app without any pattern logic. [3]

If you do need a pattern, Microsoft notes that you can ask Copilot for help creating regular expressions to use in PowerRename. [1] Start with a small example and read the preview before you apply it.

Can I rename folders too?

Yes, with the right tool. The Bulk Rename app is built to rename large amounts of files and folders, and it also lets you rename items individually when a bulk rule does not fit. [3] It also checks that your file and folder names are valid. [3]

PowerRename works on whatever you select in File Explorer, and its preview pane shows the results before you finalize anything. [1] Folders you select there appear in the list along with your files.

Is there a file manager option with a built-in bulk rename?

Yes. Some file managers include one, and the Lubuntu manual describes an example in a Linux file manager. Select the files, then choose this menu path or press Control+F2 to open a dialog: [5]

Edit --> Bulk Rename

The dialog has a Rename selected files to field, a Replacement checkbox, Find in names and Replace with fields, and a Case sensitive checkbox. [5] Check the Regular expression checkbox to use a pattern in the replacement. [5]

On Windows, File Explorer itself does not need to be replaced: after you select files in it, right-click and choose Rename with PowerRename, which appears only if the utility is enabled in PowerToys. [1]

Which approach should you take?

Start with PowerRename on a copy of a few files, and move to regex only when the job needs it. Copy five or six files into a scratch folder, select them, right-click, and choose Rename with PowerRename. [1] Try one small pattern, read the preview, and apply it only when the new names look right. If something goes wrong, Explorer’s Undo Rename (Ctrl+Z) can reverse the last change. [1]

If your job is only adding numbers or changing case, skip the pattern logic and use a simpler rule. Once a pattern works on the copies, run it on the real folder.

Sources

  1. PowerRename Utility for Windows – Bulk File Renaming Tool

  2. Aoao Batch Rename

  3. Bulk Rename is one of the most powerful and intuitive file and folder r

  4. Bulk Rename Utility 4.0.0.8 Crack + License Key [Latest]

  5. Remove text that no longer appears from bulk rename · cadb6c28ed