Rename (ren)

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Rename (ren)

Changes the name of a file or a set of files.

Syntax

rename [Drive**:**][Path] FileName1 FileName2

ren [Drive**:**][Path] FileName1 FileName2

Parameters
  • [ Drive:][ Path] FileName1
    Specifies the location and name of the file or set of files you want to rename.
  • FileName2
    Specifies the new name for the file. If you use wildcards (* and ?), FileName2 specifies the new names for the files. You cannot specify a new drive or path when renaming files.
  • /?
    Displays help at the command prompt.
Remarks
  • Renaming files

    You can rename all files matching the specified file name. You cannot use the rename command to rename files across drives or to move files to a different directory location.

  • Using wildcards with rename

    You can use wildcards (* and ?) in either file name parameter. If you use wildcards in FileName2, the characters represented by the wildcards will be identical to the corresponding characters in FileName1.

  • Rename will not work if FileName2 already exists

    If, for FileName2, you specify a file name that already exists, rename displays the following message:

    Duplicate file name or file not found

Examples

Suppose you want to change the extensions of all the file names in the current directory that have the extension .txt; for example, you want to change the .txt extensions to .doc extensions. To make this change, type:

ren *.txt *.doc

To rename a file or directory named Chap10 to Part10, type:

ren chap10 part10

Formatting legend

Format Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

See Also

Concepts

Move
Copy
Xcopy
Command-line reference A-Z
Command shell overview