How to rename a file with a Command prompt

Shaant Minhas

windows 11 bcd

Looking for more How To posts? Check out our How To Page for all the latest tips on Windows, Microsoft Teams, LinkedIn, and more!

You can do almost anything through your Command prompt that you would otherwise carry out from your computer’s GUI. Take renaming your files, for example. While the most common way to do this is by right-clicking on the file and typing up a new name, this might not work in all cases.

This is where the Command prompt can help you out. Whether it’s a single file or a batch of them, with a few short commands from the Command prompt, you can instantly rename your files. So let’s jump right in and look at how you can rename your files on Windows with only cmd.

How to rename a file with a Command prompt

You can rename a file or folder using the “ren” command on your Command prompt. Here’s how:

  1. Head to the Start menu search bar, type in ‘cmd,’ and select the best match.
  2. On your Command prompt, change your directory to where the file is in the drive. If you don’t know how to do that, check out our detailed guide on changing Windows directories on Command prompt.
  3. You can check if you are in the correct directory by looking at the files on your computer. Type in the dir command and hit Enter.
  4. Finally, to rename your files, type in the following command and hit Enter:
    ren “current_name.txt” “new_name.txt”

    For example, you can replace “current_name.txt” with OldFile.txt and “new_name.txt” with NewFile.txt. So, the final command becomes:

    ren OldFile.txt NewFile.txt

command prompt

Your file or folder will be instantly renamed after this.

Renaming multiple files with a Command prompt

We have covered how to rename a single file using the command prompt above. But what if you have to rename multiple files?

There’s no doubt that renaming every single file one by one will be a massive timesink. Thankfully, the Command prompt offers a way to tweak part of your multiples files in a single go. While I agree it would have been great if there was a way to rename the files from scratch, but for now, we have to stick with this method.

So if you want to rename some files with a similar name structure, follow the steps below:

  • On your Command prompt, head to the path where your files are located by typing in the following command and hitting Enter:
    cd c:\PATH\TO\FILES

For example, one valid path can be cd %USERPROFILE%\Movies\newfolder.
  • Once you are in the folder, type in the following command and hit Enter:

    Here, replace the “File-Extension” with the file extension of the file you want to change and “File-Name” with the new name you’d like to append to your file.
    So, a dummy example from our side will be:

    Ren “.jpg ???-marriageanniversary.*

    Here, the command renames all files by adding the “-marriageanniversary” to the end. Note that it only does this for the images with the .jpg extension.

command prompt

After you have executed the command, the files have been renamed as you have specified.

Renaming the files on your PC with the Command prompt

While you always rename your files simply through File explorer, the method doesn’t always work. Or, in some cases, you might not even want to. The methods we have laid out above will help you rename your files with the Command Prompt.

File renaming is just one of the many handy things you can do with your Command prompt. For instance, deleting files or factory resetting is another set of things achievable straight from your Command prompt.