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.
Step 2: In the Search bar, type in notepad and then click on the Notepad application from the Best match section.
Step 3: When the Notepad app opens up, copy and paste the following code snippet onto it.
@ECHO OFF PUSHD . FOR /R %%d IN (.) DO ( cd "%%d" IF EXIST *.from_extension ( REN *.from_extension *.to_extension ) ) POPD
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.
Step 4: Once you are done, click on the File tab at the top. Then click on the Save As option.
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.
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.
Step 7: After execution, you can see that the type of the files has changed to PNG.
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.
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.
Someone who is in love with writing and technical tricks & tips.