CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Windows – REN command – How to rename files or folders?

Windows provides commands to rename the file or folder from Windows command prompt. Through this Article we will discuss on renaming files and folders from Widows command prompt.

REN command – Rename files or folders

REN or RENAME command is used to rename the files or folders in Windows Operating System. We can use this command from Windows command prompt.

When you use this command without any parameters, Windows will display below message.

C:\>ren
The syntax of the command is incorrect.

Basically it takes, two parameters; one parameter is the path of the file to rename and the new name to the file. For example, below command renames “oldfile.txt” to “newfile.txt”;

C:\>ren C:\Personal\oldfile.txt newfile.txt

Once the file is renamed successfully; you will the renamed file in the location where the source file exists. Yes, this is important to understand. You can give the complete path to the source file. But the new name to the file SHOULD be, just a new name of the file; it shouldn’t have path mentioned. Because file can be renamed ONLY from the location where the file exists. If you attempt to give new location to the renamed file; Windows will show below message. And the example, like below;

C:\>ren sample.txt C:\NewFolder\sample.txt
The syntax of the command is incorrect.

You must always pass the new name to the file. If you forget to pass this; you will see the same above message;

C:\>ren sample.txt
The syntax of the command is incorrect.

Another thing you need to remember is, if the file or folder already exists with new file or folder name; you can not rename the file or folder and if you attempt to rename, you will see the below message;

C:\>ren OldFolder NewFolder
A duplicate file name exists, or the file
cannot be found.

Windows can not allow to rename the files or folders which are already using by another process. If you try to rename them, Windows will throw below message;

C:\>ren setup.exe newname.exe
The process cannot access the file because it is being used by another process.

Rename multiple files or folders at a time

Wildcards are used to rename multiple files or folders at a time. For example, below command renames all the “.txt” files to “.doc” files.

C:\>ren *.txt *.doc

Be on learning curve always!

// Malin

Windows – REN command – How to rename files or folders?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top