Rename

Advertisement

If you are using the Windows Operating System then you use the Command Prompt (aka CMD)

With the UI we can rename the files and folders.

But as a developer, It’s really easy to rename the files and folders with the command prompt

You are going to learn

Rename files or folders with REN or RENAME command Rename files or folders with REN or RENAME command

In Windows Operating System you can use the command:

  • REN

Or,

  • RENAME

Both commands are the same REN is an alias or shorthand of the RENAME command.

You can use anyone you want.

Top ↑

Syntax of REN or RENAME command Syntax of REN or RENAME command

The syntax of REN command is:

RENAME [drive:][path]filename1 filename2

The syntax of RENAME the command is the same as above like:

RENAME [drive:][path]filename1 filename2

Top ↑

Example of REN or RENAME command Example of REN or RENAME command

Suppose you have a file C:\Users\mwagh\example\ directory and it contain:

|-one
|-one.txt

Here,

  • one – It is a directory
  • one.txt – It is a text file

And you want to rename:

  • The file from one.txt with new file name two.txt
  • And, The directory one with new directory name two

To do this, Follow below steps:

Step 1: Click on windows button and type CMD
Or
Step 1: Press Windows key + R to open command prompt

Step 2: Navigate to the C:\Users\mwagh\example\ directory

Rename 1
The example directory

To see the files and folders from the example directory type

dir

And press enter key. You’ll see something as below:

Rename 2
The example details view

Rename directory or folder Rename directory or folder

Rename the directory or folder with REN command Rename the directory or folder with REN command

Now, First let’s see how to rename the directory name one with new directory name two

Type command:

ren one two
Rename 3
Rename the directory

Now, Type dir command to see the list of files and folders from example directory

Rename 4
Directory name changed

Top ↑

Rename the directory or folder with RENAME command Rename the directory or folder with RENAME command

RENAME is the alias of the REN command.

Both works same. So you can use it as:

rename one.txt two.txt

Top ↑

Rename file Rename file

Top ↑

Rename the file with REN command Rename the file with REN command

To rename the file name one.txt with new file name two.txt

Type command:

ren one.txt two.txt
Rename 5
Rename the file

Now, Type dir command to see the list of files and folders from example directory

Rename 6
See list of files and folders

Top ↑

Rename the file with RENAME command Rename the file with RENAME command

RENAME is the alias of the REN command.

Both works same. So you can use it as:

rename one.txt two.txt

Leave a Reply