Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Facebook Twitter Instagram
Tech News Today
  • Hardware
    • Motherboards
    • CPUs
    • Graphic Cards
    • RAM
    • SSDs
    • Computer Cases
    • Monitors
    • Peripherals
    • Power Supply Unit
    • PC Builds
    • Computer Tips
  • Software
  • Operating System
    • Windows
    • Mac
    • Linux
  • Gaming
  • Mobile
  • Console
  • More
    • Internet
    • Networking
    • Security
    • Buyer’s Guide
    • Gadgets
    • Laptops
    • Reviews
    • How To
    • News
Tech News Today
Home»Windows»How to Rename File on Command Prompt

How to Rename File on Command Prompt

Bishwo TamliBy Bishwo TamliFebruary 24, 2023
rename-file-cmd

The Command Prompt is a powerful tool built into most computers running the Windows operating system. It is a command line interpreter that you can use to perform just about any task, including things like renaming files.

While you can also rename files through File Explorer, doing so in Command Prompt can be much faster if you know how. Additionally, you can also batch rename files in the Command prompt which can massively increase your efficiency.

Rename Files on Command Prompt

The simplest way to rename files in Command Prompt is by going to that specific file’s directory and using the ren/rename command. Its syntax is rename filename newname. 

When using it practically, replace the filename with the file’s actual name and newname with the name you want to set. You can also use ren instead of rename as both are the same command.

However, before you go on to use the command, there are a few things to keep in mind.

  • You will need to include the file name extension in your command, as your terminal will display an error if you don’t. (If you’re renaming folders, you don’t need to do so.)
  • You also need to specify the filename extension for your newname. If you don’t, the newly renamed file will have no extension.
  • If your filename or newname contains spaces, you will need to enclose them within double quotation marks.
    renamming files with spaces in cmd

Now that you know the basic rules to follow when using the rename command, here’s how you can go about using it.

  1. Press Windows key + R key to launch Run box.
  2. Type cmd and press Enter.
    cmd on run
  3. In Command Prompt, you will need to change the active directory to the location of the file you want to rename. To do so:
    • Enter the command cd <file location path>.
      change cmd directory with cd
    • If the file you want to rename is in another drive instead of default C, you will first need to change to that specific drive. To do so, enter the drive letter followed by : For example, D:
      change drive in command prompt
    • If you don’t know how to get the file location path, navigate to the file’s location in File Explorer, and simply copy the location available in the address bar.
      file path directions
  4. Now, enter the command rename filename newname. (For example, rename Untitled.docx Schedule.docx )
  5. You can also use the same command to rename file name extensions. (For example, rename Schedule.docx Schedule.txt)
    rename files in command prompt

Additionally, if you don’t like using the cd command to change your active directory, there is another method you can use. Navigate to the file location in File Explorer, type cmd in the address bar and press Enter. This will directly open Command Prompt in that directory.

Alternatively, you can tweak the rename command a little so that you don’t have to change your directory to rename files. The syntax for this altered command is rename “file path location” newname.

For example, rename “C:\Screenshots\20190213.jpg” “Sun Tzu Quote.jpg”

Batch Rename Files on Command Prompt

The best use of the rename command is when you’re trying to rename many files simultaneously. To batch rename files in the Command prompt, you will have to know about the two key wildcards, * and ?.

Using * Wildcard

The * character is basically used to select all the files at once, but it is low in priority order. For example, the rename Photo*.jpg Image*.jpg will change any image file beginning with the name Screenshot to Image with the same characters following after.

renaming files in command prompt with asterisk

In a nutshell, if your images were labeled Photo1, Photo2, and so on, the above command will change them to Image1, Image2, and so on. 

If you want to rename files without having to specify their extensions, you can use the * wild card to do so as well. For example, rename Untitled.jpg Image.* will make sure that your renamed file has the same extension as its earlier version.

rename file extension without specifying extension in cmd

Also, you can use the * wildcard to rename all files with a particular extension to another extension. For example, rename *.txt *.docx will make sure any files with the .txt extension will get renamed to .docx.

rename file extension in cmd
Note: The dir command used in the images show all the files present in a specific directory.

Using ? Wildcard

The ? character can be used as a placeholder to replace itself with the character in the same position as itself. You can use this character in conjunction with the * character to batch rename files and trim specific files.

For instance, the rename *.* ?????.* will trim every file to its first five characters. You can add or remove as many ? wildcards to expand or lower the character count.

trim filenames from cmd

Also, you can specify the extension in the filename to only target specific files. For example, rename *.jpg ?????.* will trim every jpg file to its first five characters.

Another way you can use this ? wildcard is at the filename to specify files with varying lengths of name characters. For instance, the rename “?????.jpg” “?????2022.*” will add 2022 to every jpg file that has five characters in its name.

add characters to filename from cmd

If you’d like a more in-depth explanation on batch renaming files and wildcard characters, you can check out our other article.

how-to
Bishwo Tamli

I'm a tech enthusiast, and I've always been troubleshooting errors by myself for years. I also like keeping up to date with the latest technology and gadgets.

Related Posts

antimalware service executable high memory

Fix: Antimalware Service Executable High Memory

May 18, 2023
windows event logs

How to Check Event Logs on Windows

May 17, 2023
the rpc server is unavailable

Fix: The RPC Server is Unavailable

May 15, 2023
DirectStorage Windows 11

How to Enable DirectStorage on Windows 11

May 15, 2023
audio keeps cutting out

5 Ways to Fix Audio Keeps Cutting Out on Windows 11

May 12, 2023
MBR Error 1 2 3

What is MBR Error 1, 2, 3? 7 Ways to Fix It

May 11, 2023
Add A Comment

Leave A Reply Cancel Reply

Latest Posts
Best-1200W-PSU

8 Best 1200W PSUs for Extreme PC Builds in 2023

May 16, 2023
Best-1000W-PSU

10 Best 1000W PSUs in 2023

May 16, 2023
best-700w-psu

10 Best 700W PSUs for Gaming in 2023

May 14, 2023
You may also like
antimalware service executable high memory

Fix: Antimalware Service Executable High Memory

May 18, 2023
printer-printing-pink

Why is My Printer Printing Pink? 6 Ways to Fix It

May 18, 2023
how to clean usb c port

How to Clean USB-C Port Safely

May 17, 2023
Recommended
Cookie Clicker Garden Guide

Cookie Clicker Garden Guide to Unlocking Every Seed

September 26, 2021
monitor no signal

Computer Turns On But Monitor Says No Signal (9 Ways To Fix)

November 10, 2022
Facebook Twitter Pinterest
  • Home
  • About Us
  • Our Team
  • Editorial Guidelines
  • Privacy Policy
  • Affiliate Disclosure
© 2023 TechNewsToday, editor@technewstoday.com | Tech Central Pvt. Ltd.

Type above and press Enter to search. Press Esc to cancel.