As it’s well known to us all, CMD (Command Prompt) is a powerful Windows built-in command line tool. This tool can help users to do many different works such as CMD ping test, CMD list files, CMD copy files, CMD list drives, CMD check WiFi password, and more. However, lots of users are unclear on how to rename file using CMD. Here’s a true example from the StackOverflow forum:
How to rename files in Windows CMD (command prompt). Renaming files in Windows explorer is easy but when you need to rename many files it can become quite tedious. A command prompt (terminal) makes it easier.
When it comes to renaming file on Windows, most people may want to use File Explorer. But it is time consuming and boring if you need to rename a lot of files. A more effective way is to rename file using CMD. How to make Windows CMD rename file? Let’s keep reading.
How to check disk space PowerShell Windows 10/11? Now, you come to the right place. This post focuses on PowerShell get disk space and provides an alternative.
What Command Can Be Used to Rename Files
First of all, it’s necessary to figure out what command can be used to rename a file on Windows 10/11. The answer is to use Ren/Rename command. It can be used to rename files, directories, and file extensions. The Syntax of the CMD rename file is “rename/ren [<drive>:][<path>]<filename1> <filename2>”.
- Drive: It refers to the drive letter that contains the file or set of files you want to rename.
- Path: It specifies the directory that the folder/subfolders located on the drive.
- Filename1: It refers to the name of the file you want to rename.
- Filename2: It refers to the target name that you want to rename filename1 to. You can use the “*” wildcard characters to specify new names for multiple files.
You can neither specify a new drive or path for the renamed file nor rename file CMD across drives. In addition, the Filename2 must be a unique file name, or you will encounter the “Duplicate file name or file not found” error.
How to Rename Files in Command Prompt Windows 10/11
Now, you should have an overall understanding of the Windows CMD rename file syntax. Here we will show you how to rename file in CMD via several specified examples. Let’s start trying.
Step 1. Press the Win + E keys to open the File Explorer and navigate to the path in which you want to rename files.
Step 2. Click on the address bar and type cmd in the file path and hit Enter. It will direct you to the file path in Command Prompt.
Step 3. In the pop-up Command Prompt window, you can rename file CMD according to your needs. Here we summarize several frequently asked questions.
Example 1. CMD Rename a Specified File
ren file1.txt file2.txt
Example 2. CMD Rename File Extension
ren file1.txt file2.doc
Example 3. CMD Rename Multiple Files Extension in the Current Directory
If you want to rename multiple files at one time, you can utilize the wildcard character. The following example renames all file in the current directory that ends with .xml to .txt.
ren *.xml *.txt
Example 4. CMD Rename a Directory with a Space
For example, if you want to rename the E:Server 2016 directory to Windows Server 2016, you can navigate to the path using CMD as we explained above, and run the following command.
If you are renaming a file or directory with a space, the name must be surrounded by quotes.
ren "Server 2016" "Windows Server 2016"
Further reading: If you enter some issues like file system corruption and low disk space on Windows 10/11, don’t worry. MiniTool Partition Wizard can help you fix them easily by checking file system errors, extending/resizing partitions, analyzing disk space, upgrading to a larger hard disk, etc.