Windows command line rename

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:

  1. 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:\>
  2. You also need to have sufficient privileges to rename the file.
    c:\>rename c:\windows\csc test
    Access is denied.
    c:\>
  3. 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 to mp3 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

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.

How-to-Rename-Files-and-Folders-Using-CMD

How to Rename Files and Folders Using CMD

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’.»
rename_folder_pic2

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.
rename_folder_pic3

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.

  • 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.

type cmd in the search bar of Windows File Explorer

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

rename a specified file in CMD

Example 2. CMD Rename File Extension

ren file1.txt file2.doc

CMD rename file extension

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

rename multiple files extension using CMD

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»

rename a directory with a space using CMD

Further readingIf 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.

You can rename a file in Windows Command Prompt using the `ren` command followed by the current file name and the new file name.

ren oldfilename.txt newfilename.txt

What is the Rename Command in CMD?

The rename command in CMD is a fundamental tool for managing and organizing files. It allows users to change the names of one or more files without needing a graphical user interface, facilitating quick and efficient file management directly from the command line. The basic syntax of the rename command is:

rename [old_filename] [new_filename]

Understanding this command is essential for anyone looking to optimize their workflow in Windows.

Rename File in Cmd: A Quick Guide

Rename File in Cmd: A Quick Guide

How to Access CMD

To begin using the rename file Windows CMD, you first need to access the Command Prompt. Here’s how you can open CMD in Windows:

Opening Command Prompt

  • Using Windows Search: Simply type «cmd» in the search bar located next to the Start menu. Click on the «Command Prompt» application that appears.
  • Using the Run dialog: Press `Windows Key + R`, type `cmd`, and then press Enter.
  • From the Start menu: Navigate to the Start menu, scroll down to «Windows System», and click on «Command Prompt».

Tip: Always ensure you are in the correct directory to execute the rename command effectively.

Repair Windows Cmd: Quick Fixes and Tips

Repair Windows Cmd: Quick Fixes and Tips

Steps to Rename a File in CMD

Basic Rename Command Usage

To rename a single file, you can use the rename cmd command directly. For instance, if you wish to change a file named `mydocument.txt` to `mydocument_backup.txt`, you would enter:

rename mydocument.txt mydocument_backup.txt

This command signals to the Command Prompt that the old filename has been identified and replaced with the new one without changing the file’s extension.

Renaming Files with Extensions

Files on Windows often have extensions that determine the type of file they are. When using the rename command in CMD, it’s crucial to remember that changing the filename extension can affect how a file is opened. For example, if you want to rename `report.docx` to `report.pdf`, use the following command:

rename report.docx report.pdf

This command changes both the file’s name and its extension, effectively converting it in terms of file type.

Renaming Multiple Files

Sometimes, you may want to rename several files at once. The rename command allows for this with the help of wildcards. A wildcard (`*`) can represent any number of characters in a file name. For example, if you want to rename all `.txt` files to `.bak`, you would execute:

rename *.txt *.bak

This powerful feature can help streamline file management and reduce repetitive work.

Using CMD to Navigate Directories Before Renaming

Before running the rename command, you must be in the correct directory where the file resides. Use the `cd` command to change directories. For example, to navigate to the Documents folder, you would write:

cd C:\Users\YourUsername\Documents

Once you are in the right directory, you can run your rename file Windows CMD operations smoothly.

Create File in Cmd: A Quick Guide to Getting Started

Create File in Cmd: A Quick Guide to Getting Started

Common Errors and Troubleshooting

Access Denied Errors

One common issue users may face is an Access Denied error. This typically occurs due to insufficient permissions to modify the file or directory. Ensure you are running CMD with administrative privileges or check that the file isn’t open in another program.

File Not Found Errors

If you receive a File Not Found error while trying to rename a file, double-check the spelling of the filename and its path. Ensuring that you are in the correct directory when executing the command is vital.

Rename Folder Cmd: A Quick Guide to Mastering It

Rename Folder Cmd: A Quick Guide to Mastering It

Advanced Rename Techniques

Using the `ren` Command

The `ren` command can be used interchangeably with rename. It follows the same syntax and allows for similar operations. For example, to rename `oldfile.txt` to `newfile.txt`, you can simply use:

ren oldfile.txt newfile.txt

Creating Batch Scripts for Renaming

If you frequently rename files, you might consider creating a batch file to automate the process. A batch script is a text file that contains a series of commands to be executed by the command-line interpreter. Here’s a simple example of a batch script that renames all `.jpg` files to `.png`:

@echo off
rename *.jpg *.png

Saving this code in a `.bat` file and running it will apply the rename operation to all files with the specified extensions in the current directory.

Make File in Windows Cmd: A Quick Guide

Make File in Windows Cmd: A Quick Guide

Summary

The rename command in CMD is an efficient tool for managing files directly from the command line. Its straightforward syntax and the ability to handle individual files or batches make it an invaluable skill for users looking to enhance their file management capabilities. The key takeaways include understanding the command’s syntax, navigating directories, and troubleshooting common errors. Mastering these techniques will empower you to streamline your workflow and elevate your confidence in using the Command Prompt.

Read File in Cmd: A Simple Guide to Easy File Access

Read File in Cmd: A Simple Guide to Easy File Access

Further Resources

For those interested in expanding their knowledge beyond the rename file Windows CMD, numerous online resources and CMD command references can provide deeper insights into the extensive capabilities of CMD. Exploring these materials will help enhance your proficiency and explore more advanced command-line functionalities.

Sleep Windows Cmd: Mastering Sleep Commands in Cmd

Sleep Windows Cmd: Mastering Sleep Commands in Cmd

Conclusion

The significance of mastering the rename command in CMD cannot be overstated. It simplifies the file management process and enhances productivity. As you practice and explore various CMD commands, you will likely find that CMD becomes a vital tool in your computing toolkit. Start leveraging these commands today to improve your efficiency!

From Wikipedia, the free encyclopedia

ren / rename

The ReactOS ren command

Developer(s) Various open-source and commercial developers
Operating system OpenVOS, RT-11, OS/8, RSX-11, ISIS-II, iRMX 86, TOPS-20, Z80-RIO, FLEX, CDOS, OS-9, FlexOS, PC-MOS, 4690 OS, MPE/iX, THEOS/OASIS, OpenVMS, CP/M, MP/M, TRIPOS, AmigaDOS, DOS, MSX-DOS, SISNE plus, OS/2, Windows, ReactOS, SymbOS, DexOS
Platform Cross-platform
Type Command

In computing, ren (or rename) is a command in various command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS, 4NT and Windows PowerShell. It is used to rename computer files and in some implementations (such as AmigaDOS[1]) also directories. It is analogous to the Unix mv command. However, unlike mv, ren cannot be used to move files, as a new directory for the destination file may not be used. Alternatively, move may be used if available. On versions of MS-DOS that do not support the move command (older than 6.00), the user would simply copy the file to a new destination, and then delete the original file. A notable exception to this rule is DOSBox, in which ren may be used to move a file, since move is not supported.

Description of the RENAME command of RT-11SJ displayed on a VT100.

The command is available in the operating systems Digital Research CP/M,[2] MP/M,[3][4] Cromemco CDOS,[5] MetaComCo TRIPOS,[6] DOS, IBM OS/2,[7] Microsoft Windows,[8] ReactOS,[9] SymbOS, and DexOS.

Multics includes a rename command to rename a directory entry. It can be contracted to rn.[10]

Stratus OpenVOS,[11] DEC RT-11,[12] OS/8,[13] RSX-11,[14] Intel ISIS-II,[15] iRMX 86,[16] TOPS-20,[17] Zilog Z80-RIO,[18] TSC FLEX,[19] Microware OS-9,[20] DR FlexOS,[21] IBM/Toshiba 4690 OS,[22] HP MPE/iX,[23] THEOS/OASIS,[24] and OpenVMS[25] also provide the rename command which in some cases can be contracted to ren.

The rename command is supported by Tim Paterson’s SCP 86-DOS.[26] On MS-DOS, the command is available in versions 1 and later.[27] DR DOS 6.0 also includes an implementation of the ren and rename commands.[28]

In Windows PowerShell, ren is a predefined command alias for the Rename-Item Cmdlet which basically serves the same purpose.[29]

TSL PC-MOS includes an implementation of rename.[30]
Like the rest of the operating system, it is licensed under the GPL v3.[31]

It is also available in the open source MS-DOS emulator DOSBox.

>ren filename newname
>ren *.htm *.html

Another example. This will rename a default video found in Windows 7 with a new name:

>rename "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv" "Wildlife2.wmv"

The first parameter may contain a drive and a path, but the second parameter must contain only the new filename.

To remove certain characters of a file name in Microsoft Windows command prompt (XP & Higher) :

>rename "abcd*.txt" "////*.txt"

This will remove abcd from the file name.

Notes:

  1. Same number of / as the number of initial characters to remove.
  2. Double quotes for both arguments.
  3. It doesn’t remove . from file name
  • List of DOS commands
  • List of PowerShell commands
  1. ^ Rügheimer, Hannes; Spanik, Christian (September 19, 1988). AmigaDOS quick reference. Grand Rapids, Mi : Abacus. ISBN 9781557550491 – via Internet Archive.
  2. ^ «Manual» (PDF). www.cpm.z80.de. Retrieved 2020-09-19.
  3. ^ Digital Research (July 1981) [1979]. MP/M — Multi-Programming Monitor Control Program — User’s Guide (PDF) (4 ed.). Pacific Grove, CA, USA: Digital Research. Archived (PDF) from the original on 2017-01-04. Retrieved 2017-01-04.
  4. ^ Digital Research (1981-09-25). MP/M-86 Operating System — User’s Guide (PDF) (1 ed.). Pacific Grove, CA, USA: Digital Research. Archived (PDF) from the original on 2017-01-04. Retrieved 2017-01-04.
  5. ^ CDOS USER’S MANUAL
  6. ^ «Manual» (PDF). www.pagetable.com. Retrieved 2020-09-19.
  7. ^ «JaTomes Help — OS/2 Commands». Archived from the original on 2019-04-14. Retrieved 2019-07-06.
  8. ^ «Microsoft TechNet Rename (ren) article». 11 September 2009.
  9. ^ «reactos/reactos». GitHub. 3 January 2022.
  10. ^ «Multics Commands». www.multicians.org.
  11. ^ «Manual» (PDF). stratadoc.stratus.com. Retrieved 2020-09-19.
  12. ^ «RT-11 HELP FILE». paleoferrosaurus.com. Archived from the original on 2018-07-17. Retrieved 2018-07-16.
  13. ^ «Concise Command Language» (CCL).«OS/8 Handbook» (PDF). April 1974. Retrieved 28 November 2017.
  14. ^ John F. Pieper (1987). RSX A Guide for Users (PDF). Digital Equipment Corporation. ISBN 0-932376-90-8. Retrieved 2020-09-19.
  15. ^ ISIS II Users Guide
  16. ^ iRMX™86 INTRODUCTION AND OPERATOR’S REFERENCE MANUAL For Release 6
  17. ^ «TOPS-20 Command manual» (PDF). Archived from the original (PDF) on 2020-08-09. Retrieved 2018-07-18.
  18. ^ Z80-RIO OPERATING SYSTEM USER’S MANUAL
  19. ^ «FLEX 2.0 User’s Manual» (PDF).
  20. ^ Paul S. Dayan (1992). The OS-9 Guru — 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
  21. ^ «FlexOS User’s Guide» (PDF). www.bitsavers.org. 1986. Archived from the original (PDF) on 2010-08-08. Retrieved 2020-09-19.
  22. ^ «Users guide» (PDF). archive.org. Retrieved 2020-09-19.
  23. ^ «MPE/iX Command Reference Manual» (PDF). Archived from the original (PDF) on 2018-10-21. Retrieved 2018-10-21.
  24. ^ THEOS/OASIS User’s Handbook
  25. ^ OpenVMS User’s Manual[permanent dead link]
  26. ^ 86-DOS — Disk Operating System for the 8086 — User’s Manual (PDF). Version 0.3 (Preliminary ed.). Seattle, Washington, USA: Seattle Computer Products, Inc. 1980. Archived from the original (PDF) on 2019-07-14. Retrieved 2019-07-14. (59 pages)
  27. ^ Wolverton, Van (2003). Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. ISBN 0-7356-1812-7.
  28. ^ DR DOS 6.0 User Guide Optimisation and Configuration Tips
  29. ^ «Microsoft TechNet PowerShell Rename-Item (ren) article». 22 October 2009.
  30. ^ PC-MOS User Guide
  31. ^ Jansen, Roeland (8 February 2018). «pcmos386v501: PC-MOS/386 v5.01 final release including cdrom driver sources» – via GitHub.
  • Wolverton, Van (1990). MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition. Microsoft Press. ISBN 978-1556152894.
  • Kathy Ivens; Brian Proffit (1993). OS/2 Inside & Out. Osborne McGraw-Hill. ISBN 978-0078818714.
  • Frisch, Æleen (2001). Windows 2000 Commands Pocket Reference. O’Reilly. ISBN 978-0-596-00148-3.
  • ren | Microsoft Docs

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Значок языка в трее windows 7
  • Thunderbolt card for windows
  • Rdp wrapper windows 10 pro
  • Нужно отключить автоматическое скрытие панели задач windows
  • Можно ли установить windows через setup exe