Last Updated :
10 Mar, 2025
Renaming files and folders is a fundamental task for system organization. While it’s simple through the graphical interface, using CMD provides more flexibility, particularly for batch operations or when the interface is unavailable.
In this guide, you’ll master the ren (or rename) command, a built-in CMD utility for renaming files and directories. We’ll cover everything from basic syntax to advanced techniques.
What is CMD?
CMD, short for Command Prompt, is the command-line interpreter application available in most Windows operating systems. It allows users to execute commands to perform tasks on their computers without using a Graphical User Interface (GUI). CMD provides a direct way to interact with the operating system by typing text commands, enabling users to run programs, manage files and directories, configure system settings, and troubleshoot various issues. It’s a powerful tool for advanced users, system administrators, and developers to automate tasks and perform system-level operations.
Steps to Rename Files and Folders Using CMD
Let’s go through a quick walkthrough of the steps involved in renaming files in cmd:
Step 1: Opening CMD
- To rename a file in the command prompt, open CMD by pressing both ‘Windows’ along with ‘R’ simultaneously then open up the ‘Run’ and type “cmd” and click the OK button. This will enable opening CMD instantly.
Step 2: Getting to the Directory- using the ‘cd’ Command
- When you have the CMD window open, go to the directory where the file or folder that you want to rename is located. You can make this possible by using the ‘cd’ command plus the path to the directory. For example, should the file be found under the ‘Documents’ folder type ‘cd Documents’ then hit ‘Enter’.»
Step 3: Renaming Files and Folders — The ‘ren’ Command
- You can use the command ‘ren’ for moving files. Let’s say we have a folder with the old name ‘Miss_named’ which we want to rename as ‘CorrectFolder’ using the command ‘ren Miss_named CorrectFolder’. For changing the name of any document or directory through the prompt type ‘ren oldname newname’ where the original filename/foldername (oldname) goes before space in single quotes followed by spaces and then what you would like it to be referred to as (newname) also in single quotes once more before hitting Enter on your keyboard.
Step 4: Renaming Multiple Files — using Wildcard Characters
- By using CMD, the renaming of multiple files simultaneously is possible. You can do that by using the wildcard character ‘*’. A good example would be when you have files in numerical order which look like ‘file1.txt’, and ‘file2.txt’ thereby having a file name beginning with “file” followed by numbers. If one wanted them within this order changed to have doc instead for example doc1.doc doc2.doc he/ she would type in ren file*.txt doc*.txt.
Important Points to Remember
- It’s crucial to remember that when using the command prompt to rename files and folders, there is no ‘undo’ option. Take care to double-check your commands before pressing ‘Enter’.
- Furthermore, if the filename or folder name contains spaces, ensure to enclose the name in double quotes. For example, ‘ren «old file.txt» «new file.txt»‘.
Conclusion
Renaming files and folders via the Command Prompt is a powerful skill that can streamline your workflow, especially when handling multiple files or folders at once. By mastering the CMD rename command, you can efficiently rename files and folders using CMD with ease and precision. Whether you’re a seasoned professional or just starting out, understanding these command-line techniques will enhance your ability to manage files on your system.
The rename command is used to rename a single file or folder from the Command Prompt.
Rename and ren can be used interchangeably. They’re the exact same command.
Rename Command Availability
The rename command is available from within Command Prompt in most versions of Windows, including Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server operating systems, and some older versions of Windows, too.
This is also a Recovery Console command available from within the Recovery Console in Windows 2000 and Windows XP.
Rename Command Syntax
rename [drive:][path] filename1 filename2
Rename Command Options | |
---|---|
Item | Explanation |
drive: | This is the drive containing the file you want to rename. |
path | This is the folder or folder/subfolders located on the drive:, containing filename1 that you want to rename. |
filename1 | This is the name of the file you want to rename. |
filename2 | This is the name you want to rename filename1 to. You can not specify a new drive or path for the renamed file. |
Rename Command Examples
Below are several examples showing how you can use the rename command.
Rename File in Specified Folder
rename c:\windows\win.ini win.old
In the above command, we’re renaming win.ini, located in the C:\Windows folder, to win.old.
Rename File in the Same Folder
rename boot.new boot.ini
In this one, the rename command has no drive: or path information specified, so the boot.new file is renamed to boot.ini, all within the directory you typed the rename command from.
For example, if you type rename boot.new boot.ini from the C:\> prompt, the boot.new file located in C:\ will be renamed to boot.ini.
Rename File Extension and Name
ren file.bak regfile.reg
In this example, the rename command (shortened here to ren) is used to rename just the file extension, similar to the two example above.
We’re renaming a backup with the bak file extension to a file with the REG file extension so that we can restore it to the Windows Registry (something you can only do if it ends in .reg).
However, we’re also changing the name of the file to regfile, something we can do inside the same command so that we don’t have to run two separate commands.
Changing the file extension doesn’t actually change the file’s format. Unlike a file converter tool which formats the actual file itself, the ren command can only adjust the suffix. In most situations, like in the example above, this results in Windows treating it differently (e.g., now it can open in Windows Registry).
Rename a Folder
ren pictures "vacation pics"
In this last sample, we’re using the rename command to rename a folder instead of a file. The pictures folder will become vacation pics. Quotes are used around the folder name since it contains a space.
Rename Related Commands
This command is often used with the dir command so that you can see the list of filenames within Command Prompt before choosing which one to rename.
The ren command can’t specify a different drive or path when renaming files. Instead, the cd command can be used with the rename command to change the working directory in Command Prompt to wherever the file or folder is located.
Thanks for letting us know!
Get the Latest Tech News Delivered Every Day
Subscribe
on June 11, 2014
Rename file from command line [CMD]
We can use the command rename
to rename files from windows command prompt(CMD). Find below syntax of the command with examples.
Syntax of rename command:
rename file_path new_name
Example:
rename d:\data\file1.doc file2.doc
After executing the above command we’ll have file2.doc in the folder d:\data
Ren
is alias for rename
, so both refer to the same command.
Errors:
- If the files is being used by a program, then rename command fails with below error.
C:\>rename data.xlsx newdata.xlsx The process cannot access the file because it is being used by another process. C:\>
- You also need to have sufficient privileges to rename the file.
c:\>rename c:\windows\csc test Access is denied. c:\>
- Rename changes just the file name, it does not convert a file from one type to another. For example, if you rename a file from
mp4
tomp3
extension, it does not change the file format. Renaming a doc file'mydocument.docx'
to'mydocument.pdf'
does not make the file readable in Acrobat Reader.
More Reading
Rename file extensions in batch from command prompt
-
Home
-
Partition Manager
- CMD Rename Files: How to Rename Files in Command Prompt
CMD Rename Files: How to Rename Files in Command Prompt
By Ariel | Follow |
Last Updated
What command can be used to rename file CMD? A lot of users are confused about this question. Now, this post of MiniTool explains the CMD rename file process using different examples.
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.
https://stackoverflow.com/questions/63396610/how-to-rename-files-in-windows-cmd-command-prompt
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.
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.
Note:
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.
Tips:
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.
About The Author
Position: Columnist
Ariel has been working as a highly professional computer-relevant technology editor at MiniTool for many years. She has a strong passion for researching all knowledge related to the computer’s disk, partition, and Windows OS. Up till now, she has finished thousands of articles covering a broad range of topics and helped lots of users fix various problems. She focuses on the fields of disk management, OS backup, and PDF editing and provides her readers with insightful and informative content.
The ren
(or rename
) command can be used to rename files and folders in the Window command prompt (CMD).
The syntax of the rename
command is as follows:
rename file-name new-file-name
Examples
Rename file1.txt to file2.txt:
ren file1.txt file2.txt
Rename the name of a directory from Pictures to Documents:
ren Pictures Documents
Use quotation marks if the file or folder name contains spaces:
ren "New folder" "Documents"
The ren
command supports wildcards to rename multiple files at once. For example, the following command renames the extension of all files in a folder (from .txt
to .doc
):
ren *.txt *.doc
Note that you can’t move files from one directory to another with the ren
command. For that, use the move command.