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.
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
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 nametwo.txt
- And, The directory
one
with new directory nametwo
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
To see the files and folders from the example directory type
dir
And press enter key. You’ll see something as below:
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
Now, Type dir
command to see the list of files and folders from example directory
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
Rename file Rename file
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
Now, Type dir
command to see the list of files and folders from example directory
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