≡ Menu

Rename file from command line

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\file1.doc   file2.doc

After executing the above command we’ll have file2.doc in the folder d:\data

Change file extensions in bulk 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

rename  *.html   *.txt

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

 

{ 3 comments… add one }
  • Aaron Brinkley August 11, 2015, 12:18 am

    Does the command have to be executed in the root directory, or can it be done in a subdirectory that is in the root directory? Also, can a directory be renamed (EXAMPLE: renaming Dell.dir to Newname.dir)?

  • ritz December 22, 2015, 3:15 pm

    this command gives repeating of filename when there are more then 40 files in the folders ?
    any solution for renaming 100s of file ???

Leave a Comment