Переименовать файл консоль windows

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:

  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

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

rename files windows

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 files windows

rename files

Rename the name of a directory from Pictures to Documents:

ren Pictures Documents
cmd rename folder

rename folders

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.

Программистам часто приходится работать в консоли — например, чтобы запустить тестирование проекта, закоммитить новый код на Github или отредактировать документ в vim. Всё это происходит так часто, что все основные действия с файлами становится быстрее и привычнее выполнять в консоли. Рассказываем и показываем основные команды, которые помогут ускорить работу в терминале под OS Windows.

Для начала нужно установить терминал или запустить командную строку, встроенную в Windows — для этого нажмите Win+R и введите cmd. Терминал часто встречается и прямо в редакторах кода, например, в Visual Studio Code.

Чтобы ввести команду в консоль, нужно напечатать её и нажать клавишу Enter.

Содержимое текущей папки — dir

Выводит список файлов и папок в текущей папке.

C:\content-server>dir
 Том в устройстве C имеет метку SYSTEM
 Серийный номер тома: 2C89-ED9D

 Содержимое папки C:\content-server

06.10.2020  00:41    <DIR>          .
06.10.2020  00:37    <DIR>          .circleci
16.07.2020  16:04               268 .editorconfig
16.07.2020  16:04                10 .eslintignore
16.07.2020  16:04               482 .eslintrc
06.10.2020  00:37    <DIR>          .github
16.07.2020  16:04                77 .gitignore
06.10.2020  00:41    <DIR>          assets
06.10.2020  00:41    <DIR>          gulp
16.07.2020  16:10               379 gulpfile.js
16.07.2020  16:10           296 320 package-lock.json
16.07.2020  16:10               751 package.json
16.07.2020  16:04               509 README.md

Открыть файл

Чтобы открыть файл в текущей папке, введите его полное имя с расширением. Например, blog.txt или setup.exe.

Перейти в другую папку — cd

Команда cd без аргументов выводит название текущей папки.

Перейти в папку внутри текущего каталога:

C:\content-server>cd assets
C:\content-server\assets>

Перейти на одну папку вверх:

C:\content-server\assets>cd ..
C:\content-server>

Перейти в папку на другом диске:

c:\content-server>cd /d d:/
d:\>

Чтобы просто изменить диск, введите c: или d:.

Создать папку — mkdir или md

Создаём пустую папку code внутри папки html:

d:\html>mkdir coded:\html>dir

 Содержимое папки d:\html

03.11.2020  19:23    <DIR>           .
03.11.2020  19:23    <DIR>           ..
03.11.2020  19:25    <DIR>           code
               0 файлов              0 байт
               3 папок  253 389 438 976 байт свободно

Создаём несколько пустых вложенных папок — для этого записываем их через косую черту:

d:\html>mkdir css\js
d:\html>dir
 Том в устройстве D имеет метку DATA
 Серийный номер тома: 0000-0000

 Содержимое папки d:\html

03.11.2020  19:23    <DIR>           .
03.11.2020  19:23    <DIR>           ..
03.11.2020  19:25    <DIR>           code
03.11.2020  19:29    <DIR>           css

Создаётся папка css, внутри которой находится папка js. Чтобы проверить это, используем команду tree. Она показывает дерево папок.

Удалить папку — rmdir или rd

Чтобы удалить конкретную папку в текущей, введите команду rmdir:

d:\html\css>rmdir js

При этом удалить можно только пустую папку. Если попытаться удалить папку, в которой что-то есть, увидим ошибку:

d:\html\css>d:\html>rmdir css
Папка не пуста.

Чтобы удалить дерево папок, используйте ключ /s. Тогда командная строка запросит подтверждение перед тем, как удалить всё.

d:\html>rmdir css /s
css, вы уверены [Y(да)/N(нет)]? y

Показать дерево папок — tree

В любом момент мы можем увидеть структуру папок. Для этого используется команда tree.

d:\html>tree
Структура папок тома DATA
Серийный номер тома: 0000-0000
D:.
├───code
└───css
    └───js

Если вы хотите посмотреть содержимое всего диска, введите tree в корне нужного диска. Получится красивая анимация, а если файлов много, то ещё и немного медитативная.

Удаление файла — del или erase

Команда для удаления одного или нескольких файлов.

d:\html>del blog.txt

Переименование файла — ren или rename

Последовательно вводим ren, старое и новое имя файла.

d:\html>dir
 Содержимое папки d:\html

03.11.2020  19:23    <DIR>            .
03.11.2020  19:23    <DIR>            ..
03.11.2020  19:59                 0 blag.txt

d:\html>ren blag.txt blog.txt

d:\html>dir
 Содержимое папки d:\html

03.11.2020  19:23    <DIR>            .
03.11.2020  19:23    <DIR>            ..
03.11.2020  19:59                 0 blog.txt

Команды одной строкой

Очистить консоль — cls.

Информация о системе — systeminfo.

d:\html>systeminfo

Имя узла:                         DESKTOP-6MHURG5
Название ОС:                      Майкрософт Windows 10 Pro
Версия ОС:                        10.0.20246 Н/Д построение 20246
Изготовитель ОС:                  Microsoft Corporation
Параметры ОС:                     Изолированная рабочая станция
Сборка ОС:                        Multiprocessor Free

Информация о сетевых настройках — ipconfig.

d:\html>ipconfig
Настройка протокола IP для Windows
Адаптер Ethernet Ethernet 2:

   Состояние среды. . . . . . . . : Среда передачи недоступна.
   DNS-суффикс подключения . . . . . :

Список запущенных процессов — tasklist.

c:\>tasklist

Имя образа                     PID Имя сессии          № сеанса       Память
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0         8 КБ
System                           4 Services                   0     2 688 КБ
Secure System                   72 Services                   0    23 332 КБ
…

Справка по командам — help

Команда help без аргументов выводит список всех возможных команд. help вместе с именем команды выведет справку по этой команде.

d:\html>help tree
Графическое представление структуры папок или пути.

TREE [диск:][путь] [/F] [/A]

   /F   Вывод имён файлов в каждой папке.
   /A   Использовать символы ASCII вместо символов национальных алфавитов.

В этой статье приведены не все команды и не все их возможности, но вы всегда можете воспользоваться командой help и узнать о том, что ещё может командная строка.

👉🏻 Больше статей о фронтенде и работе в айти в телеграм-канале.

Подписаться

Материалы по теме

  • 10 горячих клавиш VS Code, которые ускорят вашу работу
  • Полезные команды для работы с Git
  • Полезные команды для работы с Node. js

«Доктайп» — журнал о фронтенде. Читайте, слушайте и учитесь с нами.

ТелеграмПодкастБесплатные учебники

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

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Установка appx на windows 10 mobile
  • Установка exe на windows 10 mobile
  • Моргает панель задач windows 11
  • Журнал событий windows ошибка 4201
  • Генератор ssl сертификатов windows