on January 2, 2009
In Renaming files from command line we saw how to rename files using Rename command. We can use Rename command to rename directories too. See the syntax below.
Rename dir_oldname dir_newname
Example:
G:\data>mkdir dir1 G:\data>dir /b dir1 G:\data>rename dir1 dir2 G:\data>dir /b dir2 G:\data>
Note that, with rename command, we can’t move the files to another drive or directory. This command just renames the existing file/folder and does not create a new file. That is why it does not accept full path for the target file name. If you try to do that you will get the error – “The syntax of the command is incorrect.”
Example:
C:\docs>ren 1.txt c:\docs\2.txt The syntax of the command is incorrect.
The below rename command works fine.
C:\docs>ren c:\docs\1.txt 2.txt C:\docs>dir /b 2.txt
We can also use ren (the short form of rename) for rename operations. Both Ren and Rename refer to the same command.
This command can be used to rename files or directories on all Windows OS editions i.e Windows 2000, XP, Vista and Windows 7.
Related Posts:
Delete directory from Windows command line
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 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.
In this article, we will show you how some quick steps in order to rename folder in CMD or Command-Line in both operating systems such as Windows and Linux. Geeks and experts love the Command-Line because of the advanced commands it can run. Fortunately, Command-Line is not built only on advanced commands, but also on simple ones, designed to perform basic operations. Just in case if you want to rename the file using Command Line (CMD) & PowerShell check our previous article – “ Batch script rename file using Command Line (CMD) & PowerShell – Windows 10 “
What you need to know before starting rename folder
- You must have written or modified permissions to a file, folder, or directory to rename it. In some cases, you may need administrator privileges in the operating system to rename.
- Whenever dealing with a file or directory with space, it must be surrounded by quotes. Otherwise, you’ll get the “The syntax of the command is incorrect.” error.
- With ren command, you can’t move the files to another drive or directory. This command just renames the existing file/folder and does not create a new file. That is why it does not accept the full path for the target file name. If you try to do that you will get the error – “The syntax of the command is incorrect.”
Windows CMD Rename Folder
To rename files and folders, you need to use the REN (Rename) command. Because you cannot have a file and directory of the same name, you won’t need to worry about mistakenly renaming a file instead of a directory. The only exception is if you’re using wild characters. To rename a folder in the command line, type the following command:
ren Folder NewFolderName.
Note: We can also use ren (the short form of rename) for rename operations. Both Ren and Rename refer to the same command.
For example, if we wanted to rename the HelloWorld folder to HelloWorld_2021, we should run “ren HelloWorld HelloWorld_2021” and press Enter.
Step 1: Change the location in order to select the folder you want to rename by typing the following command:
cd D: D:
Windows CMD Rename Folder
Step 2: Rename folder in CMD using ren command:
ren HelloWorld HelloWorld_2021
Rename folder in cmd
Linux Rename Folder Command
You need to use the mv command to rename and move files and directories/folders. Everything is a file under Linux or Unix-like operating system including folders.
The procedure to rename a folder or directory on Linux:
- Open the Terminal application.
- The pwd commandshows current working directory:
pwd
mv command syntax form is as follows:
mv old-name new-name mv [options] old-name new-name mv [options] source target
- To rename a directory called HelloWorld to Hello in the current directory:
pwd ls -l mv HelloWorld Hello
- Verify it with the ls command:
ls –l
If the Hello folder is located in the same directory as the pics folder, then the HelloWorld folder can only be renamed. Hence always use pwd command and ls command to find out your current working directory.
Renaming folders may seem like a simple and straightforward task to carry out in Windows 11 using its in-house tool, Command Prompt. But what if you wish to rename a bunch of folders simultaneously? For these tasks, a tool with an easy and simple graphical user interface, such as the Easy File Renamer can be a wonderful alternative.
Bulk Rename your Files/Folders with Easy File Renamer.
This software is digitally signed and a safe download.
Renaming Folders Using Command Prompt in Windows 11
Here are some benefits of using Command Prompt in Windows 11:
-
- Command Prompt is pre-installed on Windows 11. You can start renaming files without having to download a special tool.
-
- Command Prompt helps system administrators perform file management operations faster. They can create complex folder structures, copy/ move files, and execute scripts more efficiently.
-
- Command Prompt makes complex tasks — such as retrieving specific system configurations, manipulating disk partitions, managing Windows services, and changing network configurations — much easier.
-
- CMD gives system administrators more control over their system without a graphical user interface.
- CMD helps administrators diagnose various system problems and fix issues in real time.
Steps
There are two ways by which you can rename a folder using Command Prompt in Windows 11.
Opening Command Prompt
First and foremost, you’ll need to open Command Prompt. To open Command Prompt, type “CMD” in the Search Box.
If the folder you want to rename is located in a system directory, right-click on “Command Prompt” and select “Run as administrator”. If the folder is located elsewhere, simply click on the “Command Prompt”.
Important: You must use double quotes if your folder paths contain spaces. If you don’t enclose your folder paths in double-quotes, your command will return an error.
To rename your folders, use one of the following commands:
Method 1: Change Active Directory & Rename Multiple Folders
In this method, we’ll first change the current path in the Command Prompt window to the parent directory containing your folder. We’ll then execute the “Ren” (rename) command to rename our folder.
Use this command if you wish to rename a bunch of folders located in the same directory. It’ll save you from the hassle of entering full folder paths in every command.
-
- cd “D:\TestFolder”
-
- ren “folder1” “folder1_new”
- ren “folder2” “folder2_new”
Method 2: Specify Full Folder Path
In this method, we’ll specify the full paths to the folder we want to rename. This command is not recommended if you wish to rename a lot of folders in the same path.
-
- ren “D:\TestFolder\folder1” “folder1_new”
- ren “D:\TestFolder\folder2” “folder2_new”
Batch Rename Folders Using Easy File Renamer (EFR)
There’s no denying that Command Prompt is a powerful tool, but sometimes it can be challenging for an average PC user to write and execute complex commands.
Easy File Renamer is a simple tool with a user-friendly interface. It provides dozens of renaming commands to batch rename files and folders with a single click.
Here is a list of renaming commands available in the EFR:
-
- New name: Rename your files with a completely different name than before.
-
- Replace text: Overwrite specific texts from the file names.
-
- Remove text: Remove specific instances of texts from file names.
-
- Insert At: Insert new characters into file names at specified indexes.
-
- Numbering: Add numbering to files with the same common text.
-
- Trim text: Remove a specific number of characters from the beginning and end of the filenames.
-
- Prefix: Add a text at the beginning of the filenames.
-
- Suffix: Add a text at the end of the filenames. You can add a suffix before the file extension, or after the file extension.
-
- Upper case: Change the text case of the file names to uppercase.
-
- Lower case: Change the text case of the file names to lowercase.
-
- Title case: Change the text case of the file names to the title case. Title case is often used for headings.
- Swap: Use the swap renaming rule to change the position of two texts separated by a separator.
Steps:
- Download and install the tool Easy File Renamer.
- Click on ‘System Renamer’.
- Click on the ‘Folders’ section.
- Click on the ‘Add Folder’ tab.
- Choose a folder that contains the subfolders that you want to rename.
- Your folders will appear in the list.
- Select a renaming rule from the left-side panel. For example: To add a suffix to your folders, select the “Suffix” renaming rule. Enter a text you want to add (for example, _important). Click on ‘Add Rule’.
- The added rule will appear under Applied Rules. You can add more rules and remove the existing ones if you want.
- Click on the Rename button to start renaming.
Features of Easy File Renamer:
-
- Cloud Renamer: With your subscription to EFR, you get complimentary access to Cloud Renamer. Batch rename files on multiple cloud accounts such as Dropbox, OneDrive, and Google Drive, without downloading them.
-
- Music Fixer: Do you have multiple MP3 files with empty or incorrect music tags? You can fix them all using the Music Fixer feature. Music Fixer helps you add details like the name of the album, artist, year, etc. as tags to hundreds of files with one click.
- Move & Copy: Moving and copying multiple files/ folders at once can be troublesome using Windows 11 Command Prompt. With the EFR, you can now batch move/ copy files with zero chances of errors.
Conclusion
You can rename your folders using either Command Prompt or a dedicated file renamer tool. However, typing command-line syntax can be a complex job for non-technical users, and it is prone to mistakes. The use of Easy File Renamer requires no knowledge of complex command-line context. It’s fast, easy and beginner-friendly.
