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
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.
На момент последней проверки у меня было более 500 000 файлов в папках «Документы» и «Фотографии». Поскольку я не собираюсь перебирать такое количество файлов и давать им новое имя по отдельности, я решил пакетно переименовать файлы Windows, чтобы сохранить рассудок.
1. Пакетное переименование с помощью PowerToys
PowerToys – это специализированное программное обеспечение Microsoft для опытных пользователей Windows. Среди его многочисленных функций есть PowerRename, более продвинутый и глубокий способ пакетного переименования файлов в Windows. Я загрузил ее из Microsoft Store, но она также доступна на GitHub.
Что мне нравится, так это то, что PowerRename автоматически интегрируется в контекстное меню правой кнопки мыши без необходимости делать что-либо еще. Теперь я могу выбрать все файлы, которые хочу пакетно переименовать, щелкнуть правой кнопкой мыши один из них и выбрать PowerRename. Конечно, в Windows 11 это скрывается под Показать дополнительные параметры.
Интересно: Анализ системы с помощью инструментов командной строки lscpu и lsusb
Быстрый совет: Если вы выбираете каждый файл в папке, нажмите Ctrl A, чтобы выбрать все. Если вы выбираете только некоторые файлы, удерживайте Ctrl при выборе каждого файла.
Выберите любые параметры, например конкретное слово или число, а затем выберите, чем заменить этот текст. Это очень целенаправленный способ пакетного переименования файлов.
Например, я заменяю слово Another в файлах на First. PowerRename выбирает только их и показывает предварительный просмотр конечного результата, прежде чем я что-то изменю. Если вас все устраивает, нажмите Применить.
Моя любимая функция – изменение форматирования текста. Легко переключаться между всеми строчными буквами, всеми заглавными буквами, заглавным регистром и выделением каждого слова заглавными буквами.
2. Простое переименование с помощью проводника
Если вам не нужно ничего сложного, используйте File Explorer для пакетного переименования файлов в Windows. Это быстро и просто.
Откройте папку с файлами, выделите все, что хотите изменить, и щелкните правой кнопкой мыши по первму файлу, который хотите переименовать (или нажмите F2). Введите новое имя файла, нажмите Enter, и все файлы получат одинаковые имена с последовательными номерами.
Этот метод лучше всего подходит для группировки файлов, например, серии файлов. Я изменил случайные имена на Важные заметки. Он также отлично подходит для фотографий, например, можно изменить стандартные имена в телефоне на что-то вроде Отпуск на пляже.
Хотя вы не можете изменить расширения файлов или то, как Windows добавляет номера, например, начиная с другого номера, есть несколько более продвинутых методов.
Если у вас возникли проблемы с File Explorer, узнайте, как исправить распространенные проблемы и перезапустить его.
3. Переименование расширений с помощью командной строки
Вам нужно пакетно переименовать расширения и файлы? Нажмите Win R, введите cmd
и нажмите OK, чтобы открыть Командную строку.
Измените каталог на папку, в которой находятся ваши файлы, введя полный путь или открыв папку в File Explorer. Щелкните правой кнопкой мыши местоположение пути над списком файлов и выберите Копировать адрес . Вы даже можете использовать Command Prompt для поиска файлов.
Введите cd
в командной строке и скопируйте адрес из File Explorer. Если у вас возникли проблемы с копированием и вставкой, возможно, вам нужно изменить настройки, чтобы включить функцию копирования и вставки в командной строке.
Введите следующую команду, используя нужные расширения файлов:
ren *.fileext1 *.fileext2
В моем случае я меняю расширение .jpg на .png. Обратите внимание, что при этом не меняется тип файла, а только расширение.
Если вы хотите пакетно переименовать имена файлов, процесс будет аналогичным. Однако если в именах файлов используется много символов, может возникнуть ошибка, связанная с дублированием файлов. Чтобы этого не произошло, используйте подстановочные знаки, которые представляют собой вопросительные знаки, чтобы сохранить уникальную часть исходного имени.
Сменив каталог командной строки на папку с файлами, введите следующее:
ren *.fileext ???name.fileext
Введите столько символов, сколько вам нужно. Если в имени файла нужен пробел, заключите имя файла в кавычки, например ?Имя файла.jpg. Если вы хотите, чтобы новое имя файла было в начале, используйте подстановочные знаки после имени файла, например FileName??. В моем случае я использую:
ren *.jpg ?????????January.jpg
Честно говоря, этот метод оказывается сложным. Если все файлы изначально не имеют одинаковой длины имени, то изменится только часть файлов.
4. Использование Windows PowerShell
Windows PowerShell – это что-то вроде Command Prompt на стероидах, хотя эти две программы в чем-то похожи. Для пакетного переименования файлов в Windows с помощью PowerShell вам понадобится всего несколько простых команд.
Щелкните правой кнопкой мыши папку с файлами и выберите Открыть в терминале. Терминал – это комбинированный инструмент Windows для PowerShell, Command Prompt и Azure Cloud Shell. По умолчанию он должен открываться в PowerShell.
Как только PowerShell будет открыт, используйте команду, приведенную ниже. При использовании команды не забудьте изменить TestName на желаемое имя файла и использовать правильное расширение файла.
dir | %{$x=0} {Rename-Item $_ -NewName "TestName$x.jpg"; $x++ }
Приведенная выше команда берет все файлы в каталоге и передает их команде Rename-Item
, которая переименовывает все файлы в TestName. Символ * обозначает числа, и эти числа присваиваются рекурсивно с помощью $x . Это позволяет каждому файлу иметь уникальное имя.
Если вы хотите изменить расширения всех файлов в каталоге, воспользуйтесь командой ниже.
Get-ChildItem *.jpg | Rename-Item -NewName { $_.Name -replace '.jpg','.png' }
Все, что имеет формат .jpg, меняется на .png одним нажатием кнопки.
Советую посмотреть документацию Microsoft для получения дополнительных параметров, которые можно использовать с этой командой.
5. Расширенное массовое переименование с помощью утилиты массового переименования
Да, встроенные инструменты работают удивительно хорошо для пакетного переименования файлов в Windows. Но если вам нужны еще более мощные функции, попробуйте воспользоваться утилитой Bulk Rename Utility. Этот бесплатный инструмент от сторонних разработчиков превосходит все ожидания. Она не для слабонервных, но я знаю, что вы полюбите ее, когда попробуете.
Добавляйте/удаляйте символы, добавляйте текст, добавляйте даты, изменяйте расширения, используйте свойства Windows, используйте метаданные EXIF и многое другое. Я даже могу использовать список CSV для пакетного переименования. Просто введите параметры (не обязательно использовать все поля), просмотрите и переименуйте. Для изменений, которые я делаю регулярно, я сохраняю параметры, чтобы использовать их позже.
Я также пробовал FileRenamer и Advanced Renamer, но этот вариант, как правило, самый сложный.
From Wikipedia, the free encyclopedia
The ReactOS |
|
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.
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:
- Same number of
/
as the number of initial characters to remove. - Double quotes for both arguments.
- It doesn’t remove
.
from file name
- List of DOS commands
- List of PowerShell commands
- ^ Rügheimer, Hannes; Spanik, Christian (September 19, 1988). AmigaDOS quick reference. Grand Rapids, Mi : Abacus. ISBN 9781557550491 – via Internet Archive.
- ^ «Manual» (PDF). www.cpm.z80.de. Retrieved 2020-09-19.
- ^ 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.
- ^ 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.
- ^ CDOS USER’S MANUAL
- ^ «Manual» (PDF). www.pagetable.com. Retrieved 2020-09-19.
- ^ «JaTomes Help — OS/2 Commands». Archived from the original on 2019-04-14. Retrieved 2019-07-06.
- ^ «Microsoft TechNet Rename (ren) article». 11 September 2009.
- ^ «reactos/reactos». GitHub. 3 January 2022.
- ^ «Multics Commands». www.multicians.org.
- ^ «Manual» (PDF). stratadoc.stratus.com. Retrieved 2020-09-19.
- ^ «RT-11 HELP FILE». paleoferrosaurus.com. Archived from the original on 2018-07-17. Retrieved 2018-07-16.
- ^ «Concise Command Language» (CCL).«OS/8 Handbook» (PDF). April 1974. Retrieved 28 November 2017.
- ^ John F. Pieper (1987). RSX A Guide for Users (PDF). Digital Equipment Corporation. ISBN 0-932376-90-8. Retrieved 2020-09-19.
- ^ ISIS II Users Guide
- ^ iRMX™86 INTRODUCTION AND OPERATOR’S REFERENCE MANUAL For Release 6
- ^ «TOPS-20 Command manual» (PDF). Archived from the original (PDF) on 2020-08-09. Retrieved 2018-07-18.
- ^ Z80-RIO OPERATING SYSTEM USER’S MANUAL
- ^ «FLEX 2.0 User’s Manual» (PDF).
- ^ Paul S. Dayan (1992). The OS-9 Guru — 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
- ^ «FlexOS User’s Guide» (PDF). www.bitsavers.org. 1986. Archived from the original (PDF) on 2010-08-08. Retrieved 2020-09-19.
- ^ «Users guide» (PDF). archive.org. Retrieved 2020-09-19.
- ^ «MPE/iX Command Reference Manual» (PDF). Archived from the original (PDF) on 2018-10-21. Retrieved 2018-10-21.
- ^ THEOS/OASIS User’s Handbook
- ^ OpenVMS User’s Manual[permanent dead link]
- ^ 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)
- ^ Wolverton, Van (2003). Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. Microsoft Press. ISBN 0-7356-1812-7.
- ^ DR DOS 6.0 User Guide Optimisation and Configuration Tips
- ^ «Microsoft TechNet PowerShell Rename-Item (ren) article». 22 October 2009.
- ^ PC-MOS User Guide
- ^ 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