Home  >  Article  >  How to rename the extension of all files within a folder, including subfolders

How to rename the extension of all files within a folder, including subfolders

WBOY
WBOYforward
2023-04-14 12:22:132128browse

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.

Rename the extensions of all files in the folder

Step 1: Click the Search icon on the taskbar.

How to rename the extension of all files within a folder, including subfolders

Step 2: In the search bar, enter notepad, then select from BEST MATCH SECTION CLICK NOTEPAD APP.

How to rename the extension of all files within a folder, including subfolders

advertise

Step 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

Note: Please replace

from_extension> with the old extension and with the new extension. In the example screenshot below, I changed the extension from jpg to png. So my will be a jpg and my will be a png. You can change from any extension to any other extension. jpg to png is just an example.

How to rename the extension of all files within a folder, including subfolders

Step 4: Once completed, click the File tab at the top. Then click on the Save as option.

How to rename the extension of all files within a folder, including subfolders

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.

How to rename the extension of all files within a folder, including subfolders

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.

How to rename the extension of all files within a folder, including subfolders

Step 7: After execution, you can see that the file type changes to PNG.

How to rename the extension of all files within a folder, including subfolders

Step 8: If you go into subfolders and subfolders of subfolders, you can see that the file extensions inside also change became a PNG.

How to rename the extension of all files within a folder, including subfolders

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!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete