Rename windows file cmd windows

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

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

Ariel

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.

Renaming 1 file in cmd is very easy:
In this example we have a sample1.txt and we want to change its name to sample2.txt:

    in command prompt type:
    c:\temp> ren sample1.txt sample2.txt [enter]

Let’s say the filename is sample1-some-unwanted-text-1234.txt and we want to change it to sample1.txt:

    in command prompt, type:
    c:\temp> ren sample1-some-unwanted-text-1234.txt sample1.txt

Renaming 1 file by replacing multiple unwanted characters using a star:
Let’s say the filename is sample1-some-unwanted-text-1234.txt and we want to change it to sample1.txt without having to type the whole filename:

    in command prompt:
    c:\temp> ren sample1*.txt sample1.txt

This * basically means any characters inbetween sample1 and .txt will be replaced.

Renaming multiple files with similar names
If you want to rename multiple files, i.e. sample1 2020-08-01.txt, sample2 2020-08-05.txt, sample3 2020-08-10.txt,sample4 2020-08-13.txt, you want to keep the first 7 characters you want to get rid of the dates:

    in command prompt:
    c:\temp> ren sample?*.txt sample?.txt

In this example, you want to keep the word sample and the number X (where X can be any number or character). Using a ? will leave the number in place and * instructs the rename-command to replace any characters in between sampleX and .txt

Warning: It happens very quickly that a command prompt rename operation renames too many files and you can’t undo it. So, when renaming multiple files it is advisable to make a copy of all the files you want to rename, put them in a temp folder, then run your rename commands in the temp folder, and when you’re certain that it works, go back and rename the original files.

С помощью командной строки можно выполнять любые операции с файлами и папками. Например, их можно редактировать, копировать, перемещать или переименовывать. В данной статье мы рассмотрим именно переименования. Здесь вы узнаете, как переименовать файл или папку в командной строке Windows 10 или Windows 7.

Команда RENAME (REN)

Для переименования файлов и папок в командной строке Windows 10 или Windows 7 нужно использовать команду REN (или ее синоним RENAME). Данная команда принимает путь к файлу, который нужно переименовать, и новое название. Синтаксис команды выглядит следующим образом:

rename [<drive>:][<path>]<filename1> <filename2>

ren [<drive>:][<path>]<filename1> <filename2>
[<drive>:] Диск, на котором расположен файл или каталог, который нужно переименовать.
[<path>] Путь к файлу.
<filename1> Имя файла
<filename2> Новое имя для файла.

Важные замечания:

  • Команда rename позволяет использовать подстановочные знаки (* и ?). С их помощью можно переименовать сразу несколько файлов. Замененные подстановочными знаками символы будут идентичными символам из исходного имени.
  • Новое имя (<filename2>) должно быть уникальным. Если такое имя уже занято, то будет выведена ошибка.
  • Команду rename нельзя использовать для перемещения файлов в другую папку или на другой диск.

Примеры переименования

Для того чтобы переименовать файл в текущей папке достаточно ввести команду «ren» и указать старое и новое название. Например:

ren file.txt new_name.txt

переименовать файл в текущей папке

Для переименования сразу нескольких файлов можно использовать подстановочные знаки (* и ?). Например, для того чтобы изменить расширение всех файлов с html на txt нужно выполнить следующую команду:

ren *.html *.txt

переименования сразу нескольких файлов

Таким же образом переименовываются и папки.

переименовывать папки

Если в названии файла или папки имеются пробелы, то такие названия нужно заключать в двойные кавычки. Например:

ren "file name.txt" "new name.txt"

пробелы в названии файла

При необходимости можно указать полный путь к исходному файлу, который нужно переименовать. Например, для того чтобы переименовать документ «new name.txt» в папке «d:\temp\» нужно выполнить следующую команду:

ren "d:\temp\new name.txt" my-file.txt

полный путь к исходному файлу

Обратите внимание, если вы создаете командный файл (*.bat, *.cmd), то для корректного переименования файлов или папок с кирилличными символами, текст команд должен быть сохранен в DOS-кодировке (CP866).

Akelpad

Сохранить в такой кодировке можно с помощью текстового редактора Akelpad (скачать).

Посмотрите также:

  • Как изменить расширение файла в Windows 7
  • Как передать файл большого размера через Интернет
  • Как закрепить BAT-файл на панели задач или в меню «Пуск»
  • Как быстро выделить сразу все файлы в папке
  • Как изменить дату создания (изменения) файла в его свойствах

Автор
Александр Степушин

Создатель сайта comp-security.net, автор более 2000 статей о ремонте компьютеров, работе с программами, настройке операционных систем.

Остались вопросы?

Задайте вопрос в комментариях под статьей или на странице
«Задать вопрос»
и вы обязательно получите ответ.

Командная строка WindowsХотя командная строка в Windows это далеко не такой же мощный инструмент по сравнению с терминалом в Linux, она обладает множеством базовых функций. Сегодня поговорим о переименовании файлов и каталогов.

За переименование файлов и папок в командной строке Windows отвечает команда RENAME. Можно использовать и укороченный вариант REN. Поскольку использовать укороченный вариант явно проще, в дальнейшем в этой статье будем использовать его.

Синтаксис команды ren очень прост для понимания:

REN [путь_к_файлу]\[текущее_имя_файла] [новое_имя_файла]

Если речь идёт о текущем каталоге, то достаточно команды

ren primer.txt new_primer.txt

Эта команда переименует файл primer.txt в new_primer.txt.

Если речь идёт не о текущем каталоге, то требуется указать полный путь к файлу:

ren "c:\program files\primer.txt" new_primer.txt

При указании нового имени нельзя задать другой каталог. Команда ren только даёт новое имя файлу, не перемещая его.

Аналогично можно переименовать и папку:

ren c:\primer "new primer"

Обратите внимание, что наличие пробела заставляет нас использовать кавычки.

Команда ren допускает и работу с несколькими файлами. Но тут нужно сделать весомую оговорку — ren работает с файлами и папками, у которых одно местоположение. Что это значит на практике? Задать одно и то же имя нескольким файлам одновременно команда ren не позволит. Ведь местоположение этих файлов совпадает. В этом случае будет выведена ошибка «файл с таким именем уже существует или не найден». Причем первый по имени файл всё таки будет переименован.

Переименование файлов и папок через командную строку Windows

А вот массово изменить расширение файлов команда ren способна. Для этого можно ввести команду вида

ren *.txt *.doc

Это изменит всем файлам в текущем каталоге расширение с txt на doc.

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

  • Removewat активатор для windows 7 32 bit
  • Reset windows update tool windows 10 как пользоваться
  • Reset windows installer что это
  • Rempl что это за папка в windows 10
  • Reset windows update agent скачать для windows 10