How to Rename the Extensions of all Files inside a Folder Including Sub Folders

Let’s say you need to rename the extension of a file from one extension to another, say jpg to png. It’s simple, of course! But what if you have multiple files that require extension change? Or even worse, what if these multiple files are located inside multiple folders and subfolders too, inside a single folder? Well, for a normal person, this can be a nightmare. But for a geek, definitely not. Now the question is, are you a geek or not. Well, with  The GEEK Page right here to help, you definitely are!

In this article, we explain through the method of batch scripting how you can easily rename the extensions of all files inside a folder including subfolders from one extension to the other, of your choice.

Note: Please note that in this example we have converted JPG files to PNG files. You can do other extension renamings like .mod to .mp4 etc.

Rename the Extensions of all Files inside a Folder

Step 1: Click on the Search icon on the Taskbar.


1 Search Icon Optimized


Step 2: In the Search bar, type in notepad and then click on the Notepad application from the Best match section.


2 Search Notepad Optimized


Step 3: When the Notepad app opens up, copy and paste the following code snippet onto it.

FOR /R %%d IN (.) DO (
cd "%%d"
IF EXIST *.from_extension (
REN *.from_extension *.to_extension

Note: Please replace <from_extension> with the old extension and <to_extension> with the new extension. In the following example screenshot, I’m changing the extension from jpg to png. So my <from_extension> would be jpg and my <to_extension> would be png. You can change from any extension to any other extension. jpg to png is just an example.


3 Code Snippet Optimized


Step 4: Once you are done, click on the File tab at the top. Then click on the Save As option.


4 Save As Optimized


Step 5: In the Save As window, navigate to the folder where your files, that need the extension change, are present at.

Now, give a name to your script file. I have given the name as jpg_to_png.bat. You can give any name, but the extension should be .bat.

Now, choose Save as type as All files.

Hit the Save button once you are all done.


5 Save File Optimized


Step 6: As next, go to the location where you have saved the batch file. This is the folder that contains all your jpg files. This folder can contain subfolders that have jpg files. All the jpg files inside all the subfolders will now be converted to png.

Double click on the batch file to execute it.

Note: Please note that before executing the batch file, the type of the files is JPG.


6 Execute Optimized


Step 7: After execution, you can see that the type of the files has changed to PNG.


7 Changed To Png Optimized


Step 8: If you go inside the subfolders and inside subfolders’ subfolders too, you can see that the extensions of the files inside also have changed to PNG.


8 Sub Sub Sub Changed Optimized


That’s it. You have now successfully changed from one extension to another for multiple files recursively with just a single click.

Hope you found the article useful.