The Blog Contains Information About Blogging. It has Blogger Widgets, templates and Much More About Blogging.

Saturday 26 October 2013

rename commandRen or rename command can be used to rename a directory, folder, file with the help of this command it is very easy to rename a file, the syntax of the command is also very easy and simple. This blog will guide you how to change the directory name or file name or file extension in command line.

Renaming a File

We can use the built-in command line utility rename to rename a file. Note that this command is just to rename a file keeping it in the same location and can’t be used to rename as a file in a different folder. Syntax of rename command:

rename  file_path   new_name
Example:
rename  d:\data\file.html   file2.html
After executing the above command we’ll have file2.doc in the folder d:\data

Change file extensions using rename command:

We can change the extension of a set of files in one step using rename command. For example, you have set of files with extension .html and you want to rename them to .txt.  You can do this with the below command We can change the extension of a set of files in one step using rename command. For example, you have set of files with extension .html and you want to rename them to .txt.  You can do this with the below command
rename  *.html   *.txt

Rename command works in all Windows versions   XP, Vista and Windows 7.

Renaming a Directory


We can use Rename command to rename directories too. See the syntax below.
Rename  dir_oldname  dir_newname

Example:
G:\data>mkdir dir1
G:\data>dir /b
dir1
G:\data>rename dir1 dir2
G:\data>dir /b
dir2
G:\data>

Note that, with rename command, we can’t move the files to another drive or directory. This command just renames the existing file/folder and does not create a new file.  That is why it does not accept full path for the target file name. If you try to do that you will get the error – “The syntax of the command is incorrect.
Example:
C:\docs>ren 1.txt c:\docs\2.txt
The syntax of the command is incorrect.

The below rename command works fine.
C:\docs>ren c:\docs\1.txt 2.txt
C:\docs>dir /b
2.txt

We can also use ren (the short form of rename) for rename operations.  Both Ren and Rename refer to the same command.This command can be used to rename files or directories on all latest Windows .
Posted by John Peter on 08:36 | No comments | Categories: ,

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive

Blog Archive

Bookmark Us

Delicious Digg Facebook Favorites More Stumbleupon Twitter

Text Widget

Sample Text

Download