How to replace the file extensions of several files
It may be necessary to rename several file extensions to allow compatibility with another program. An example where this could be used is renaming an ASP (Active Server Pages) file to an HTML (HyperText Markup Language) file.
It is important to realize that renaming a file extension does not change the file type. For example, you cannot rename a file with a ".txt" extension to a ".jpg" and make it an image. To change the file type, you must convert the file. With an ".exe" file and other file extensions, you may need to use a program to create the file.
Renaming in MS-DOS and the Windows command line
To rename file extensions from the Windows command line, open the command prompt and follow these steps.
Rename a file extension, keeping the original name
Use the following command at the MS-DOS or Windows command line or in a batch file.
xcopy *.shn *.wav
Using a wildcard lets you rename all files in the current directory with .shn to a .wav, while keeping the original files and extensions.
Rename and replace files with a file extension
To rename the extensions without keeping the original file, use the rename command to rename files in the current directory.
rename *.shn *.wav
Rename a single file and extension
To rename a single file and extension, use the full file name and file extension as shown below.
rename hope.txt hope.html
In the example above, the "hope.txt" text file would be renamed "hope.html".
Rename a single file to a different file extension and file name
To rename the file extension and file name, use a command like the following example.
rename hope.txt computer.html
In the example above, the "hope.txt" text file would be renamed to "computer.html".
For further help with renaming a file, folder, or directory, see: How to change or rename a file, folder, or directory.
Rename a single file with the move command
Like the rename command, use the move command to rename a file, as shown below.
move hope.txt hope.html
In the example above, the "hope.txt" text file would be renamed to "hope.html".
Renaming in Linux
Open the Linux terminal or command line and use the following commands to replace a file extension.
In the Linux command line, rename a file extension using the mv (move) command, as shown below.
mv hope.txt hope.html
In the example above, the "hope.txt" text file would be renamed to "hope.html".
To rename all files ending with .txt to .html, use a wildcard instead of the file name, as shown below.
mv *.txt *.html