PowerRename is a bulk renaming tool that enables you to:
- Modify the file names of a large number of files (without giving all of the files the same name).
- Perform a search and replace on a targeted section of file names.
- Perform a regular expression rename on multiple files.
- Check expected rename results in a preview window before finalizing a bulk rename.
- Undo a rename operation after it is completed.
In this demo, all instances of the file name "foo" are replaced with "foobar". Since all of the files are uniquely named, this would have taken a long time to complete manually one-by-one. PowerRename enables a single bulk rename. Notice that the Explorer's "Undo Rename" (Ctrl+Z) command enables the ability to undo the last change.
After selecting some files in Windows File Explorer, right-clicking and selecting PowerRename (which will appear only when enabled in PowerToys), the PowerRename window will appear. The number of items you've selected will be displayed, along with search and replace values, a list of options, and a preview window displaying results of the search and replace values you've entered.
Enter text or a regular expression to find the files in your selection that contain the criteria matching your entry. You will see the matching items in the Preview window.
Enter text to replace the Search for value entered previously that match your selected files. You can view the original file name and renamed file in the Preview window.
Options - Use Regular Expressions
If checked, the Search value will be interpreted as a regular expression (regex). The Replace value can also contain regex variables (see examples below). If not checked, the Search value will be interpreted as plain text to be replaced with the text in the Replace field.
For more information regarding the Use Boost library option in the settings menu for extended regex functionalities, see the regular expressions section.
Options - Match All Occurrences
If checked, all matches of text in the Search field will be replaced with the Replace text. Otherwise, only the first instance of the Search for text in the file name will be replaced (left to right).
For example, given the file name:
- Search for:
- Rename with:
The value of the renamed file would result in:
- Match All Occurrences (unchecked):
- Match All Occurrences (checked):
Options - Case Sensitive
If checked, the text specified in the Search field will only match text in the items if the text is the same case. Case matching will be insensitive (not recognizing a difference between upper and lowercase letters) by default.
Options - Apply to: Filename only
Only the file name portion (not the file extension) is modified by the operation. For example:
Options - Apply to: Extension only
Only the file extension portion (not the file name) is modified by the operation. For example:
Options - Include Files
Deselecting causes files to not be included in the operation. Only folders will be included.
Options - Include Folders
Deselecting causes folders to not be included in the operation. Only files will be included.
Options - Include Subfolders
Deselecting causes files within folders to not be included in the operation. By default, all subfolder items are included.
Options - Text Formatting
Select between four options to either convert items to be all lowercase, all uppercase, title case (first character of name is capitalized), or capitalize each word.
Options - Enumerate Items
Appends a numeric suffix to file names that were modified in the operation. For example:
Replace using file creation date and time
The creation date and time attributes of a file can be used in the Replace with text by entering a variable pattern according to the table below. Selecting the tool-tip in the Replace with field allows you to view and select from the supported patterns.
||Year represented by a full four or five digits, depending on the calendar used.|
||Year represented only by the last two digits. A leading zero is added for single-digit years.|
||Year represented only by the last digit.|
||Name of the month|
||Abbreviated name of the month|
||Month as digits with leading zeros for single-digit months.|
||Month as digits without leading zeros for single-digit months.|
||Name of the day of the week|
||Abbreviated name of the day of the week|
||Day of the month as digits with leading zeros for single-digit days.|
||Day of the month as digits without leading zeros for single-digit days.|
||Hours with leading zeros for single-digit hours|
||Hours without leading zeros for single-digit hours|
||Minutes with leading zeros for single-digit minutes.|
||Minutes without leading zeros for single-digit minutes.|
||Seconds with leading zeros for single-digit seconds.|
||Seconds without leading zeros for single-digit seconds.|
||Milliseconds represented by full three digits.|
||Milliseconds represented only by the first two digits.|
||Milliseconds represented only by the first digit.|
For example, given the file names:
powertoys.png, created on 11/02/2020 (november second)
powertoys-menu.png, created on 11/03/2020 (november third)
Enter the criteria to rename the items:
- Search for:
- Rename with:
The value of the renamed file would result in:
For most use cases, a simple search and replace is sufficient. There may be occasions, however, in which complicated renaming tasks require more control. Regular Expressions can help.
Regular Expressions define a search pattern for text. They can be used to search, edit and manipulate text. The pattern defined by the regular expression may match once, several times, or not at all for a given string. PowerRename uses the ECMAScript grammar, which is common amongst modern programming languages.
To enable regular expressions, check the Use Regular Expressions check box.
Note: You will likely want to check Match All Occurrences while using regular expressions.
To use the Boost library instead of the standard library, check the Use Boost library option in the PowerToys settings. It enables extended features, like lookbehind, which are not supported by the standard library.
Examples of regular expressions
Simple matching examples
||Match the beginning of the filename|
||Match the end of the filename|
||Match all the text in the name|
||Match text that begins with "foo"|
||Match text that ends with "bar"|
||Match text that begins with "foo" and ends with "bar"|
||Match everything up to "bar"|
||Match everything between "foo" and "bar"|
Matching and variable examples
When using the variables, the "Match All Occurrences" option must be enabled.
|Search for||Replace With||Description|
||Prepends "foo_" to the existing file name|
||Appends "_foo" to the existing file name|
||Appends ".txt" extension to existing file|
||Appends ".txt" extension to existing file name only if it does not have an extension|
||Move numbers in the filename: "29-03-2020" becomes "2020-03-29"|
Additional resources for learning regular expressions
There are great examples/cheatsheets available online to help you
File List Filters
Filters can be used in PowerRename to narrow the results of the rename. Use the Preview window to check expected results. Select the column headers to switch between filters.
Original, the first column in the Preview window switches between:
- Checked: The file is selected to be renamed.
- Unchecked: The file is not selected to be renamed (even though it fits the value entered in the search criteria).
Renamed, the second column in the Preview window can be toggled.
- The default preview will show all selected files, with only files matching the Search for criteria displaying the updated rename value.
- Selecting the Renamed header will toggle the preview to only display files that will be renamed. Other selected files from your original selection will not be visible.
Additional options can be configured from the PowerRename tab in the Settings menu as described below:
|Show PowerRename in||When opening the context menu for a file, this setting defines whether PowerRename appears as one of the default options or only in the extended context menu|
|Enable auto-complete for the search and replace fields||Automatically suggest terms to use in the search and replace fields based on prior uses of PowerRename|
|Maximum number of items||The largest number search and replace suggestions to display|
|Show recently used strings||When opening PowerRename, populate the search and replace fields with the last values used|
|Use Boost library||Enable extended RegEx functionality. See Regular Expressions above for more details|