The ren and rename commands change the name of files and directories.

Availability

Ren and rename are internal commands that are available in the following Microsoft operating systems.

In earlier releases of MS-DOS, instead of using ren or rename, you need to use the move command to rename directories or files.

  • Availability

  • Ren and rename syntax

  • Ren and rename examples

  • All Versions of MS-DOS

  • Windows 95

  • Windows 98

  • Windows ME

  • Windows NT

  • Windows 2000

  • Windows XP

  • Windows Vista

  • Windows 7

  • Windows 8

  • Windows 10

  • Windows 11

Ren and rename syntax

Renames a file/directory or files/directories.

RENAME [drive:][path][directory name1 | file name1] [directory name2 | file name2] REN [drive:][path][directory name1 | file name1] [directory name2 | file name2]

Ren and rename examples

rename c:\computer hope

Change the name of the directory “computer” to “hope.”

You cannot specify a new drive or path for the destination of a renamed file.

rename *.txt *.bak

Rename all text files with the “.txt” file extension to files with “.bak” extension.

rename * 1_*

Rename all files to begin with 1_. The asterisk (*) in the command above is an example of a wild character and can represent one or more characters. With only an asterisk, all file names in the current directory are renamed to have “1_” as the first two characters.

When renaming files using an asterisk (*), keep in mind that you can rename all files in a directory. If there are files in the current directory you don’t want renamed, make your rename less greedy by adding a file extension.

rename “computer hope.txt” “example file.txt”

Rename the file “computer hope.txt” to “example file.txt”. When you are dealing with a file or directory with a space, it must be surrounded by quotes. Otherwise, you get an error indicating that “The syntax of the command is incorrect.”

To represent or match one single character only, use the question mark (?) character instead.

This command doesn’t append or add text to the front of the file name; it replaces the first two characters of every file in the current directory. For example, if there was a file named hope.txt, it would be renamed to 1_pe.txt.

  • Getting ‘The syntax of the command is incorrect’ error.
  • How to copy, move, or rename files with a space in the name.
  • How to change or rename a file, folder, or directory.
  • See our rename definition for further information and related links on this term.