Suppose you need to rename a file's extension from one extension to another, such as jpg to png. It's easy, of course! But what if you have multiple files whose extensions need to be changed? Or worse, what if these multiple files are also located in multiple folders and subfolders, within a single folder? Well, for a normal person, this can be a nightmare. But for a geek, absolutely not. The question now is, are you a geek? Well, with the help of geekspage, you definitely are!
In this article, we explain how to easily rename the extension of all files within a folder, including subfolders of your choice, from one extension to another through a batch script method.
NOTE: Please note that in this example we have converted the JPG file to a PNG file. You can do other extension renaming such as .mod to .mp4 etc.
Step 1: Click the Search icon on the taskbar.
Step 2: In the search bar, enter notepad, then select from BEST MATCH SECTION CLICK NOTEPAD APP.
advertiseStep 3: When the Notes application opens, copy and paste the following code snippet into it.
@ECHO OFFPUSHD .FOR /R %%d IN (.) DO (cd "%%d"IF EXIST *.from_extension (REN *.from_extension *.to_extension))POPD
from_extension> with the old extension and
Step 4: Once completed, click the File tab at the top. Then click on the Save as option.
Step 5: In the "Save as" window, navigate to need to change the extension The folder where the file named is located.
Now, give your script file a name. I have given the name jpg_to_png.bat. You can provide any name, but the extension should be .bat.
Now, select Save as type as All files.
Click the Save button when finished.
Step 6: Next, go to the location where the batch file is saved. This is the folder that contains all the jpg files. This folder can contain subfolders with jpg files. All jpg files in all subfolders will now be converted to png.
Double-click the batch file to execute it.
Note: Please note that before executing the batch file, the file type is JPG.
Step 7: After execution, you can see that the file type changes to PNG.
Step 8: If you go into subfolders and subfolders of subfolders, you can see that the file extensions inside also change became a PNG.
That’s all. Now you can successfully change the extension of multiple files from one extension to another with just one click.
The above is the detailed content of How to rename the extension of all files within a folder, including subfolders. For more information, please follow other related articles on the PHP Chinese website!