Renaming Files Using the Command Line

by Barry Dysert
(last updated April 28, 2014)


If you don't mind doing a little more typing and a little less mouse clicking, you can perform a lot of actions from the command line. (Displaying the Command Prompt Window is covered under another tip.) One thing you can do from the command line is rename files. The command-line rename command is REN (or RENAME) and it takes two parameters. The first parameter specifies the file that is to be renamed, and the second parameter specifies what its new name should be.

Let's say you have a file called "C:\Temp\OldFile.txt" and you want to rename it to be "NewFile.txt". You would type the following at the command line:

C:\> REN C:\Temp\OldFile.txt NewFile.txt

Note the fact that the second parameter to the REN command does not include any path information but the first one does. This means you cannot rename a file to a different device or directory.

You can also rename multiple files at once by using the wildcard characters "?" and "*". The "?" character stands for exactly one actual character in the file name; the "*" character stands for one or more actual characters in the file name. So, for example, you can easily rename all of the .tmp files in a given directory to instead be .txt files:

C:\> REN *.tmp *.txt

You can use the "?" to be more specific and/or rename only a part of the file name. Let's say you have several files in a folder and some are named like "file01.tmp", "file02.tmp", "file03.tmp", etc. You just want to rename the "file??.tmp" files to have a ".txt" extension. One way to do this is like this:

C:\> REN file??.tmp file*.txt

You can even rename part of the name piece (regardless of extension) with a little creativity. So if the files to be renamed are like "file01.txt" and "file02.txt" the following command will rename them to "file71.txt", "file72.txt":

C:\> REN file??.tmp file7?.txt

Finally, you can use REN to remove pieces of a file name. Say that you have files named "Jan-numbers.xlsx", "Feb-numbers.xlsx", thru "Dec-numbers.xlsx". You can rename these files to remove the "-numbers" part of the name like so:

C:\> REN ???-numbers.xlsx ???.xlsx

The rename command, especially with wildcards, can be a great timesaver if you're careful with your parameters. Personally, if I want to do anything more sophisticated than the examples presented here I use one of the free file-renamer tools available from various download sites.

 This tip (13085) applies to Windows 7.

Author Bio

Barry Dysert

Barry has been a computer professional for over 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...


Choosing an Icon Size for the Taskbar

Choosing an icon size for the taskbar is a quick and simple process. This tip explains how it's done.

Discover More

Understanding the Search Index

You can utilize Explorer's search utility to find text within files. To make searches fast, Windows maintains a search index ...

Discover More

Understanding the Videos Folder

The Videos folder is one of several system libraries created in Windows by default. This library is specifically optimized to ...

Discover More
More WindowsTips

Introduction to Regular Expressions

Regular expressions are usually the domain of computer programmers. There are times, though, when an end-user might find that ...

Discover More

Using the Findstr Command

Finding data within files is a common need. If what you're looking for is in a flat file, you can find what you're after ...

Discover More

Switching Between Command Line and File Explorer

Sometimes you can be more effective in a command window, and other times you can be more effective using File Explorer. This ...

Discover More

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two minus 2?

2017-01-01 05:58:17


Hi Elizabeth. Yes, those were the good old days. But some of the skills we used back then still come in handy today. Maybe it's time to knock the rust off your DOS memory and get back into some command-line stuff. Sometimes that's better than winding your way through the Windows UI.

2017-01-01 03:35:06


Thx Barry. I used to work in Command prompt all the time in the early computer days but have entirely forgotten everything I knew since computers got more sophisticated for users. AH, those were the good 'ol days.

2016-02-17 14:01:03

Navaid Mansoor

Dear Barry ..Tnx for the response.
I have multiple files in one Dir names are 100.pdf , 101.pdf, 103.pdf etc
I need to rename these to
396.pdf, 397.pdf , 398.pdf etc.
I managed thru combined use of Excel and Powershell commands (copied off the net).
But i was wondering if i can do it without power shell. Powershell had to be used as some filenames had spaces and DOS ren command wouldn't recognise it.

2016-02-12 05:23:54


I'm not sure what you're trying to do. As you can see, you can't rename a set of files into just one file. Are you trying to copy all of the 2014*.TXT files into one HF.TXT file? If so, you can do that with COPY. But if you're trying to rename, there are some free renaming utilities that you could try.

2016-02-12 04:43:56

Navaid Mansoor

I wish to rename only one file FROM MANY at a time

Any file starting with 2014*.jpg should be renamed to hf.jpg
next file starting with 2014.jpg should be renamed to ewi.jpg and so on.

REN 2014*.Txt HF.TXT

But it gives error
filename not found or duplicate filename (because it has already converted first file and tries to convert all other before going to next command).
pls assist.

Newest Tips

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.