Microsoft DOS ren and rename

Updated: 05/09/2017 by Computer Hope

About ren and rename

Used to rename files and directories from the original name to a new name.

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

Availability

The ren and rename commands are internal commands that are available in the below Microsoft operating systems.

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

Ren and rename syntax

Renames a file/directory or files/directories.

RENAME [drive:][path][directoryname1 | file name 1] [directory name 2 | file name 2]
REN [drive:][path][directoryname1 | file name 1] [directory name 2 | file name 2]

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

Ren and rename examples

rename c:\computer hope

Rename the directory computer to hope.

rename *.txt *.bak

Rename all text files to files with .bak extension.

rename * 1_*

Rename all files to begin with 1_. The asterisk (*) in the above command is an example of a wild character and can represent one or more characters. With nothing placed before or after the first asterisk, all files in the current directory are renamed with a "1_" as the first two characters of the file name.

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

Note: This command does not 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.

rename "computer hope.txt" "example file.txt"

Rename the file "computer hope.txt" to "example file.txt". Whenever dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise, you'll get the The syntax of the command is incorrect error.

Additional information