Ren (Rename)

Index
Ren (Rename)
Renaming Multiple Files

Renames a file or directory. Ren and Rename are synonymous.

Syntax

REN "name" "newname"

nameThe current name of a file or directory
newnameThe new name for the file or directory

Notes:

  1. The REN command is for renaming a file or directory, not moving it.

  2. Renaming a folder will not change its creation date.

  3. 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
     
    C:\WINDOWS>_

  4. 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.

  5. 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.

  6. 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.

  7. If the file being renamed has a long filename, name can be specified using either the long or short (8.3) form.

  8. 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).

  9. REN will accept wildcards (* and ?) but often not in the way that would be expected - see Renaming Multiple Files.

Examples:

  1. To rename "chapter10.doc" to "part10.doc":
    REN chapter10.doc part10.doc

  2. 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.

  3. 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.

File Details:

Internal


This page last revised:
December 9, 1999.