January 5, 2025

For a file, there are two important components. First there is the file name and next is the file type (or the extension). So a file named support.doc will have the file name as “support” while it’s type as “doc” (MS Word format or any compatible document format).

It can be useful to know how to use the Windows command prompt to directly rename files and change their extensions.

For changing file names (renaming files): 

Suppose a file named afile.txt needs to be renamed to newfile.txt. This can be quickly accomplished through Windows command prompt.

To do this :

Open the command prompt and give the following command :

rename oldfilename.extension newfilename.extension

In this case, it would be :

rename afile.txt newfile.txt

cmdren0

cmdren1

The old file will be renamed and it’s old name will no longer exist.

For changing file type (file extension) :

Now, say the file type (file extension) needs to be changed, say from a .txt to .xls (text file to Excel document), then the command will still be the same, just the extension will differ :

rename oldfilename.oldextension newfilename.newextension

In this case, file name needs to be the same, just the extension will be changed, so :

rename newfile.txt newfile.xls

cmdren2

Isn’t this powerful and simple, just like all command line tools either in Windows or Linux?

By admin

Related Post