Renames a file or directory. Ren and Rename are synonymous.
REN "name" "newname"
|name||The current name of a file or directory|
|newname||The new name for the file or directory|
- The REN command is for renaming a file or directory, not moving it.
- Renaming a folder will not change its creation date.
- If a folder already exists with newname, REN quits and displays an error message:
C:\WINDOWS>REN Test2.txt Test.txt
Duplicate file name or file not found
- Either REN or MOVE can be used to rename a single file but there are differences in their behaviour:
- MOVE asks for confirmation (by default) before renaming a folder with a name already in use whereas REN simply will not do it.
- With REN, the second parameter must be a filename - no path names are acceptable. MOVE will require a path name to be specified if the file is in anything but the current directory.
- The inverted commas are only required for name and/or newname if they contain a space. Otherwise REN can handle long file names including periods and any other valid characters without difficulty. The inverted commas are required for file names with spaces because these can render the command line ambiguous.
- With or without inverted commas, it is assumed that, if the name includes one or more periods, the characters following the last period are an extension.
- If the file being renamed has a long filename, name can be specified using either the long or short (8.3) form.
- REN will work with files that have their "read-only" and/or "system" attributes set. It will not work if the "hidden" attribute is set (giving a "File not found" error).
- REN will accept wildcards (* and ?) but often not in the way that would be expected - see Renaming Multiple Files.
- To rename "chapter10.doc" to "part10.doc":
REN chapter10.doc part10.doc
- To rename "chapter 10.doc" to "part 10.doc":
REN "chapter 10.doc" "part 10.doc"
The inverted commas are necessary because of the spaces in the names.
- To rename "chapter10.doc" (on drive B:) to "part10.doc":
REN b:chapter10.doc part10.doc
Note that "part10.doc" remains on drive B's current path.