Renaming files one by one might not take much time if there are only a few files. However, if you need to rename multiple miles, you definitely want to batch or bulk rename the files.
So we have created this article to help provide you with different methods to rename your files in bulk. They provide different options, so we advise you to go through all of them and pick one according to your preference.
Why Batch Rename Files?
There are many reasons why you may want to batch rename files, such as:
How to Batch Rename Files in Windows
There are a few ways to batch rename files in Windows. You can either use the limited GUI rename ability or use the Command-line Interfaces for more options. There are dedicated naming applications available on the internet, along with Microsoft’s own PowerRename utility.
People usually want to rename files in the following manner:
So, we have explained how you’re able to perform these tasks in detail in the following subsections:
Using File Explorer’s Rename Feature
The first method to batch rename files in Windows is the one most users are familiar with, i.e., using theFile Explorer’srename feature.
However, keep in mind that it provides very limited options on the names you can set. To explain more, all the renamed files will have the same file name along with ascending numbers inside parenthesis.
To rename the files,
Using PowerRename Feature of PowerToys
PowerToys is a Microsoft Developed Tool that you can use to perform varieties of extended functions on your Windows system. One of the utilities included in the PowerToys package is thePowerRename utility.
It helps bulk rename your files while providing advanced options for searching and replacing the name parts.
To use it to batch rename your file,
There are many options you may use with this utility, such as:
Using Command Prompt
you’re able to also use the Command Prompt commandrenorrenameto batch rename files in Windows. The syntax for the command is,ren [:][] where, the parameters in the brackets ([ ]) are optional.
There are more than one ways to rename files using this command. Moreover, you can also use such commands as a batch script for future uses.
First, open the Command Prompt and change your directory to the folder whose files you wish to rename. To do so,
you’re able to also open the folder in the File explorer and entercmdon its address bar to open the Command Prompt directly at the working path.
Then, apply the steps below depending on how you want to rename the files.
Rename Extension
Removing the Initial Characters
Many users think it’s a bug, however, you can remove the initial characters from the filenames in the following manner:
Removing Parts of the Filename
It is possible to remove parts of a filename if the parts are separated by delimiters, such as space, tab, or a non-alphanumeric symbol. It helps yourename some of the portions separated by the delimiters as the new name.
In the filenameabc_def xyz.txt, the underscore ‘_’, the space ‘ ’ and the point ‘.’ are the delimiters.
However, you’re able to’t use the parts of the filename that are not separated by such delimiters as the new filename.
Let’s take an example of removing the parts on the filenames where the delimiter is an underscore “_”.
If there’s onlyone underscore, you can remove everything before the underscore by using the command below:
where,
If there are multiple underscores, such asa_b_c.txt, to remove everything except the parts after the last underscore,
The command is,
Here, tokens 1, 2, and 3 take the three portions of the filename separated by the two _ and set them to %F, %G, and %H in order. Then, it renames %F_%G_%H to %H only.
Similarly, you can rename it to other parts of the filenames, such as %F or %G (second part) by replacing the last part of the command. However,this removes the extension as well.
You can alsospecify multiple delimiters. For example, if we want to batch rename files in the form ofa_b-c.txttoa.txt, we can enter
where %F, %G, %H, %I take a,b,c and txt respectively.
However, you should keep in mind that youcan’t use the same name for multiple files. So if this method results in renaming more than one file to the same name, the command loop stops immediately.
Also, if you want to use thefor-loop in a batch script, you need to replace the ‘%’ sign with two % signs. For instance, you need to replace the variable %F with %%F. For more information on using for-loop in Command Prompt, refer to thefor Microsoft Documentation.
Appending Characters at Start or End
If you think that using the ‘*’ or the ‘?’ wildcards allows appending characters to the name, you would be incorrect. For instance, usingren .mp3 ab.mp3does not renamefile.mp3toabfile.mo3, but toable.mp3. So you need a different method.
This method uses a similar command syntax as the above method. Usually, you may use it to append some characters at the start or the end of the filename. However, if there are other delimiters in the filename, you can also add characters to the start or the end of these delimiters.
Let’s use a simple example,
Together with the above method (using part of a filename), appending characters to the name offers high customization for batch renaming files in Windows.
Appending Sequential Numbers
The above method only allows adding the same sets of characters to the filenames. If you want to append sequential numbers to the files, you need to use a batch file. Follow the steps below to do so,
Here,
Together with the previous methods, you can take out some parts of the filename and add numbers to it for easier recognition and organization. For example,11001.picfile.2022198.1211.pngand11001.picfile.2022198.1215.pngtopicfile 1.pngandpicfile 2.png
Moreover, if you want to use numbers with 0 at the start like 01, 02, 03, etc., you need to add conditions on the script, such as:
Similarly, for 001, 002, 003, etc., number format, use the else if branch to append 00 if less than 10 and append 0 if less than 100.
Taking Input From Text File
It is also possible to batch rename files by taking inputs from a text file. You also need to use a batch script for this method.
Convert to Uppercase or Lowercase
It is very easy to convert all letters to lowercase. The command is:
where, the /l flag gives the directory’s files in lowercase, causing the ren command to use lowercase for all files.Windows Command line is not case-sensitive so it thinks both uppercase and lowercase are the same characters, making it possible to use this replacement.
However, thedircommand does not have any flags for providing the filenames in uppercase. So you need to use the following batch script using the steps in theAdding Sequential Numbersmethod:
You should change.mp3to the extension of your files.
This script doesn’t change the case of the extensions. However, if you also want tochange the extensions to uppercase, replace:
Wildcard Behavior in Rename Command
As we mentioned earlier, the * and ? wildcards do not behave as you would normally think if you use them on both the source and the destination filenames
Asuperuser forumuser dbenham has explained this behavior in detail in the forum. We recommend you check the forum page to get the complete information.
Using Windows PowerShell
Windows PowerShellis a very powerful Command-line Interface that provides more options and functionalities.
Similar to Command Prompt, first, typepowershellon the address bar of the folder whose files you need to rename and press Enter. Or you can open Windows PowerShell in any other way and change to the directory.
After that, apply the methods below depending on how you want to batch rename the files.
you may use the End-of-file (eof) character$after the old extension to only allow the last instance of the extension to change. For example,
There’s also another way to rename the extension, which uses theSystem.IOclass. The syntax for this method is:
You can also use the-Recurseflag forGet-ChildItemto allow the command to work on all the files in the working directory’s subfolders.
Removing or Replacing Specific Characters
Unlike Command Prompt, in PowerShell, you normally use the character replacing operator-replaceto rename files. So, you may directly replace particular sets of adjacent characters with a new one or set the replacement to an empty value to remove the characters.
For example, to renamefile 01.mp3toMusic01.mp3, you can use the command:
Removing or Replacing Characters at Any Position
To replace characters at any position in Windows PowerShell, you’re able to use the command:
while replacing the following portions:
For instance,Get-ChildItem *.mp3 | Rename-Item -NewName { $.Name.substring(2,$.Name.length-5) }renamesabcdefgh.mp3tocdefgh
A filename’s first position is zero, so the character of the new name starts from the third character. And the length is determined from the final position, which is 11 including the extension. So you are taking 11-5=6 characters to form the new name.
You need to take note of the extension length in this method. You can directly add the extension in the command to avoid having to change it again. To do so, the command for the example would be:
Appending Characters at the Start or the End
Appending the characters is more convenient with PowerShell than Command Prompt, specifically because you can use the ‘+’ operator to add the names and$_.Namevalue to get the original filename.
Similar to the above methods, it is much easier to append sequential numbers on PowerShell. Here’s how you’re able to do so:
You can replace D3 with how many digits you want. For instance,{0:D3}appends the three-digit numbers: 001, 002, and so on.
You can also place the number anywhere on the name.
Taking input from a text file is slightly more complex, so the best way to do so using this Command Line is by creating a PowerShell script. Here’s how you may do so:
You need to change.mp3to the extension of your files andfilename.txtto the text file with the list.
If you want to convert the names of text files, you need to add a condition to the script. The complete script is:
Here are the commands you may use to change the case of your files:
Using Third Party Tools
Many third-party tools like Bulk Rename Utility, File Renamer Basic, Advanced Renamer, etc., are available on the internet, which you can use to batch rename your files. These apps provide more customization and features compared to the PowerRename Utility.
You can download and use any one of them by following the tutorials from their official website.