It may be necessary to rename several file extensions to allow compatibility with another program. A good example where this could be used is renaming an ASP file to an HTML 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 the following steps.

It is important to realize 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 “.jpg” and make it an image. If you want to change the file type, you need to 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.

  • Renaming in Linux.

  • How to get to an MS-DOS prompt or Windows command line.

Rename a file extension keeping the original

Use the following command at the MS-DOS or Windows command line or within a batch file.

xcopy *.shn *.wav

Using a wildcard lets you rename all files with .shn to a .wav, while keeping the original files and extensions.

  • See the xcopy command for further information about this command.

Rename and replace files with a 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

  • See the ren and rename command and xcopy command pages for further information about these commands.

Rename a single file and 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 hope.txt hope.html

In the example above, the “hope.txt” text file would be renamed to “hope.html”.

Rename a single file with the move command

Like using the rename command, you can also use the move command to rename a file as shown.

move hope.txt hope.html

Renaming in Linux

In the Linux command line, you can rename a file and file extension using the mv (move) command as shown.

mv hope.txt hope.html

  • How to change a file extension.
  • How to change or rename a file, folder, or directory.
  • See our move, mv, and rename definition for additional information and related links.
  • Computer file help and support.