-
Notifications
You must be signed in to change notification settings - Fork 6.6k
PowerRename Overview
Have you ever needed to modify the file names of a large number of files but didn't want to rename all of the files the same name? Wanted to do a simple search/replace on a portion of various file names? Wanted to perform a regular expression rename on multiple items?
PowerRename is a Windows Shell Context Menu Extension for advanced bulk renaming using simple search and replace or more powerful regular expression matching. While you type in the search and replace input fields, the preview area will show what the items will be renamed to. You can toggle specific items to include or exclude from the operation in the preview area. Other checkbox options allow more control of scope of the rename operation. PowerRename then calls into the Windows Explorer file operations engine to perform the rename. This has the benefit of allowing the rename operation to be undone after PowerRename exits. PowerRename was designed to cover the majority of bulk rename scenarios while still striving for simplicity for the average user.
In the below demonstration, I am replacing all of the instances of "Pampalona" with "Pamplona" from all the image file names in the folder. Since all the files are uniquely named, this would have taken a long time to complete manually one-by-one. With PowerRename this takes seconds. Notice that I can undo the rename if I want to from the Windows Explorer context menu.
The text or regular expression to match in the item name
The text to replace the instance(s) in the item name matched by the Search text
If checked, the Search field will be interpreted as a regular expression. The Replace field can also contain regex variables (see examples below). If not checked, the Search field will be used as a text to be replaced with the text in the Replace field.
If checked, the text specified in the Search field will only match text in the items if the text is the same case. By default we match case insensitive.
If checked, all matches of the text in Search field will be replaced with the Replace text. Otherwise, only the first instance of the Search for text in the item will be replaced (left to right).
Files will not be included in the operation.
Folders will not be included in the operation.
Items within folders will not be included in the operation. By default, all subfolder items are included.
Appends a numeric suffix to file names that were modified in the operation. Ex: foo.jpg -> foo (1).jpg
Only the file name portion (not the file extension) is modified by the operation. Ex: txt.txt -> NewName.txt
Only the file extension portion (not the file name) is modified by the operation. Ex: txt.txt -> txt.NewExtension
File's creation date and time attributes can be used while renaming. Simply use variable pattern in Replace with
text area according to the table below to retrieve related info from files attributes.
Usage | Explanation |
---|---|
$YYYY | Year represented by a full four or five digits, depending on the calendar used. |
$YY | Year represented only by the last two digits. A leading zero is added for single-digit years. |
$Y | Year represented only by the last digit. |
$MMMM | Name of the month |
$MMM | Abbreviated name of the month |
$MM | Month as digits with leading zeros for single-digit months. |
$M | Month as digits without leading zeros for single-digit months. |
$DDDD | Name of the day of the week |
$DDD | Abbreviated name of the day of the week |
$DD | Day of the month as digits with leading zeros for single-digit days. |
$D | Day of the month as digits without leading zeros for single-digit days. |
$hh | Hours with leading zeros for single-digit hours |
$h | Hours without leading zeros for single-digit hours |
$mm | Minutes with leading zeros for single-digit minutes. |
$m | Minutes without leading zeros for single-digit minutes. |
$ss | Seconds with leading zeros for single-digit seconds. |
$s | Seconds without leading zeros for single-digit seconds. |
$fff | Milliseconds represented by full three digits. |
$ff | Milliseconds represented only by the first two digits. |
$f | Milliseconds represented only by the first digit. |
For most use cases, a simple search and replace is sufficient. Other users will need more control over. That is where Regular Expressions come in. Regular Expressions define a search pattern for text. Regular expressions can be used to search, edit and manipulate text. The pattern defined by the regular expression may match one or 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" checkbox.
Note: You will likely want to check "Match All Occurrences" while using regular expressions.
Simple matching examples:
Search for | Description |
---|---|
^ | Match the beginning of the filename |
$ | Match the end of the filename |
.* | Match all the text in the name |
^foo | Match text that begins with "foo" |
bar$ | Match text that ends with "bar" |
^foo.*bar$ | Match text that begins with "foo" and ends with "bar" |
.+?(?=bar) | Match everything up to "bar" |
foo[\s\S]*bar | Match everything between "foo" and "bar" |
Matching and variable examples: Note: For using the variables, you do need "Match All Occurrences" enabled
Search for | Replace With | Description |
---|---|---|
(.*).png | foo_$1.png | Prepends "foo_" to the existing file name |
(.*).png | $1_foo.png | Appends "_foo" to the existing file name |
(.*) | $1.txt | Appends ".txt" extension to existing file name |
(^\w+.$)|(^\w+$) | $2.txt | Appends ".txt" extension to existing file name only if it does not have an extension |
Filters can be used in PowerRename to narrow the view to the files that are going to be renamed and check their expected results. Click on the column headers to switch between filters.
Current filters
- First column cycles between Selected and Flags Applicable filter
- Selected: An item is visible if it is checked in the interface.
- Flags Applicable: An Item is visible if current flags are applicable to the file.
- Second column toggles Should Rename filter on/off
- Should Rename: An item is visible if rename operation will be performed on it.
There are great examples/cheat sheets available online to help you