Freigeben über


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

Move

Copy

Xcopy

Command-line reference A-Z