The following article will teach the methods to change the extension of multiple files at once using command prompt and batch file. Furthermore, we will explain the methods of using Powershell tools. In the end, w will recommend some tools to make the job easy.
About filenames
Windows Filenames are created from two parts, a filename, and an extension. They are separated by a full stop (a period). The filename is a descriptive label; the extension indicates the type of file you’re dealing with – PNG for an image, MP4 for a video file, DOC or DOCX for Word documents, PDF for an Adobe Reader file, and so on. You’re can change filenames as you need, but you need to know before changing file extensions because Windows uses the extension to figure out which program should be used to open a file.
How to display file extensions:
By default the extension on windows explorer is disabled and you cannot see it if you don’t change the below settings:
- Open any folder window.
- Press Alt+T+O (that’s the letter O, not a zero) to open the Folder Options dialog box.
- Click the View tab.
- Remove the tick (checkmark) beside ‘Hide extensions for known file types’ and click OK.
You need to know before making any change that you cannot rename a file extension and change the type of a file. For example, you cannot rename a file with a “.txt” extension to a “.png” and make it an image. If you want to change the file type, you need to convert the file. With a “.exe” file and other file extensions, you may need to use a program to create the file.
How to change extension of multiple files at once using File Explorer
Change file extension for one file in Windows 10:
In Windows 10, make sure file extensions are visible using the steps above, then:
- Click the file to select it, then click once more. Windows automatically selects the filename so that anything you type will replace the existing name.
- Click and drag over the extension, type the new extension, and press Enter.
It sounds simple enough, but imagine if you’re changing extensions on a bunch of files? Things get even worse if you want to change capitalized extensions on a group of files: Windows 7 cannot do it. For example, if you have three files named Test1.JPG, Test2.JPG, and Test3.JPG, if you select all the files and rename the first one Testing.jpg, you’ll end up with Testing (1).JPG, Testing (2).JPG and Testing (3).JPG. The extension pigheadedly maintains its uppercase lettering. If you want to change those extensions, you have to rename each file one by one. Let’s see the example below:
Change file extension for multiple files at once:
Just put all the files which you would like to rename, in a single folder (if they are scattered). Follow these steps and you can quickly rename all files at once in File Explorer:
- Open File Explorer in Windows 10 and browse to the folder where the files you need to rename.
- Press Ctrl +A to select all your target files. Once all the files are selected, right-click on the first file and select rename from the context menu (you can also press F2 to rename the file).
- You’ll notice only the file name itself is highlighted, not the extension. If you want to rename the full name including extension, press Ctrl + A to select all. Now type a new file name and press Enter.
- It will rename the rest of the files based on the first filename, and add the sequential number to the end of each file.
To make the things sample, come in play the command line where you can play and change the extensions easier. Read below!!!
Batch rename file extensions in bulk from CMD
Command-line (CMD) is a powerful tool where you can change many things and automate daily processes like deleting specific files. In this article, we will use it to rename file extensions in bulk.
First open a command prompt by:
- Searching on windows the “cmd” name an open as administrator
- Navigate to your path where you need to change the extension by type cd and the path
- Click Enter
You are now located in the directory/folder where are the files need to change the extension.
How to rename the single file extension
If you are only want to rename a single file and extension, you can specify the full file name and file extension as shown.
rename Test1.txt Test1.html
In the example above, the “Test1.txt” text file would be renamed to “Test1.html”.
How to rename a single file extension with the move command
Like using the rename command, you can also use the move command to rename a file as shown.
move Test1.txt Test1.html
How to rename multiple file extension
If you want to rename the extensions without keeping the original file, you can also use a command similar to the following example.
rename *.shn *.wav
The above command will change the extension of all files from .shn to .wav
ren *.* *.newextension
The above command will change the extension of all files no matter what is the extension to the new one .newextension
How to rename a file extension keeping the original
Use the following command at the Windows command line or within a batch file.
xcopy *.shn *.wav
The command will create a copy of the original files with the new extension.
Recursively batch rename file extensions
The following command will rename files from one extension to another, in all subfolders:
forfiles /S /M *.ext1 /C "cmd /c rename @file @fname.ext2"
or
FOR /R %f IN (*.kar) DO REN "%f" *.mid
For example, if you want to rename all jpg files to png files, the command would be as below:
forfiles /S /M *.jpg /C "cmd /c rename @file @fname.png"
How to remove file extensions in batch
The below command would remove the extension for the specified file types. In our example we will remove the .jpg extension from all files in the folder and subfolders:
forfiles /S /M *.jpg /C "cmd /c rename @file @fname"
How to create a batch to rename file extensions in bulk
If you are going to automate the above activities or to execute over the network you will need to create a batch file:
- Open a notepad file
- Copy the below command
@echo off Cd C:/Test forfiles /S /M *.jpg /C "cmd /c rename @file @fname.png"
- Save as changeextension.bat
- Execute the file and all the .jpg files on C:/Test will be changed to .png
Be careful when executed the batch over the network. Be Sure that C:/Test is the path where you need to make the changes as the command will change all the file extension in the folder and subfolders. If you want to change only on the folder you need to replace the command with :
rename *.shn *.wav
Change extension of multiple files at once using PowerShell
You can change/rename the extension of a file or multiple files using the ChangeExtension method:
- Open Start.
- Search for PowerShell and click the top result to open the app.
- Type the following command to rename a single file extension and press Enter:
Rename-Item -Path 'C:\Test\Test01.txt' -NewName $([System.IO.Path]::ChangeExtension('C:\Test\Test01.txt', ".old"))
- Type the following command to rename multiply file extension:
Get-ChildItem -Path C:\Test -Filter *.txt | Rename-Item -NewName {[System.IO.Path]::ChangeExtension($_.Name, ".old")}
Bonus Solution to play with the file names
How to trim multiple file names
You might want to make the file names shorter and bring more simplicity to the equation. Here is how to trim multiple names simultaneously.
For instance, you may have .jpg files that need trimming with names that have already been customized. Inside the target directory, you can add the “ren*.* ??????.*” function. This function will trim the original photos to the number of characters designated by the question marks.
This example will turn a file named “mountain_trip.jpg” into “mounta.jpg.” Of course, if the file name is six characters or less in length, it will remain the same. This is useful where short file names are a better option than long ones.
How to Add prefix to file names in batch
If you want to add any prefix to file names, it can be done as in the below example. Here we try to add ‘photo’ to every jpg file in the current folder and subfolders.
forfiles /S /M *.jpg /C "cmd /c rename @file photo@file"
Similarly, we can add a number to a file name.
forfiles /S /M *.jpg /C "cmd /c rename @file 99@file"
How to Handling names with white spaces
If the new name you want to assign to the files has white space within it, it can be done by adding double quotes around the file name. So that forfiles does not misinterpret these double-quotes, you need to escape them with ‘\’
For example, to add ” – pic.jpg” to each of the jpg files, the command would be as below.
forfiles /M *.jpg /C "cmd /c rename @file \"@fname - pic.jpg\""
Change extension of multiple files using Bulk Rename Tools
A better way to change filenames and extensions is to use tools. If you need to do some serious file renaming, try a bulk file renaming utility. Bulk Rename Utility is free to use. It has enormous power and flexibility, it makes very light work out of actions such as changing the case of a bunch of file extensions. If you want a less intimidating renamer, Better File Rename does the trick, but it’ll cost $US19.95.
Below is the guide on how to change the case of all files in a folder using Bulk Rename Utility:
- Open the folder containing the files.
- Right-click any file in the folder and choose Bulk Rename Here from the context menu. The utility will load all the files into its main window, with a folder tree displayed on the left allowing you to navigate to any other folder, and a mind-numbing array of options displayed below.
- Press Ctrl+A to select all the files in the folder.
- Down near the bottom right of the window you’ll see Extension. Select Lower from the Extension drop-down box. You’ll see the filenames updated in the New Name column. This is a preview to let you check whether the changes you’re making are correct.
- If you’re satisfied with the displayed changes, click the Rename button in the bottom right to rename the selected files.
Renaming in Linux
In the Linux command line, you can rename a file and file extension by using the mv (move) command as shown.
mv Test.txt Test.html
In the example above, the “Test.txt” text file would be renamed to “Test.html”.
Conclusion:
This is all about methods to change the extension of multiple files at once. If you have any suggestions feel free to comment below.