From time to time, I find myself wanting to rename the file extension of a specific file type. If it's just a couple of files, it nothing hard. However, where there are tens or hundreds of files spread throughout different sub-folders, you need something better. So, if you are ever in the same situation, follow the below steps to recursively bulk rename file extensions in all sub-folders.
There are quite a number of software that let you rename files and file extensions.
However, the problem is that they require you to have those files in the same folders. When the files you want to rename are located in different folders, say like the SRT files (subtitles), these programs become pretty useless in those kinds of scenarios.
Bulk Rename File Extensions in All Folders
To bulk rename file extension in all folders, the command or program you are using should recursively look for the target file type in all sub-folders in the target folder and rename. The good thing is, it is pretty easy. In fact, you don't even have to use a third-party application. A single link command will suffice. Here's how.
1. First, search for Command Prompt in the start menu and open it.
2. If the files you want to rename are in the C drive, skip this step. Otherwise, use the below command to go that drive. Don't forget to replace <DriveLetter> with the actual drive letter. In my case, I'm going to the D drive.
3. Next, use the below command to go the folder where the files are located. Replace the dummy path with the actual folder path. The command we are going to use will rename the target file type in this folder and all its sub-folders.
A quick tip: Drag and dropping the folder into Command Prompt will autofill the folder path.
4. Once you are inside the target folder, execute the below command while replacing "ext1" with the current file extension and "ext2" with the file extension you want it to be.
for /R %x in (*.ext1) do ren "%x" *.ext2
For example, if I'm trying to change the file extension from JPG to PNG then the command will look like this.
for /R %x in (*.jpg) do ren "%x" *.png
That is all. As soon as you execute the command, the Command Prompt will go through all the sub-folders in the target folder and renames the file extension.
Hope that helps. If you need any help, comment below and I will try to help as much as possible. If you like this article, do check out how to delete files using Command Prompt in Windows.