Name
ren or rename
Synopsis
Rename a file or directory.
Syntax
ren [filename1] [filename2] rename [filename1] [filename2]
Description
Use ren to rename any file or directory. Unlike
Windows Explorer, though, ren is capable of
renaming several files at once (via wildcards 8 and ?).
The ren options are:
- [
filename1] The name of the existing file or directory.
- [
filename2] The new name to assign the file or directory.
Examples
Rename myfile.txt to
file.txt:
C:\>rename myfile.txt file.txtRename chap 5.doc to sect
5.doc: (the following two methods are identical):
C:\>ren "chap 5.doc" "sect 5.doc"C:\>ren chap?5.doc sect?5.doc
Each of these examples represent different ways to rename files with
spaces in their names. In addition to the standard quotation marks,
in certain circumstances, you can use wildcards to avoid the spaces
problem. Here, both chap 5.doc and
sect 5.doc have spaces in the fifth character
position, so the single wildcard character (?) can be used.
Rename the files chap1.doc,
chap2.doc, etc. to
revchap1.doc, revchap2.doc,
etc.:
C:\>ren chap*.doc revchap*.doc
ren can be a convenient way to rename the filename
extensions of several files at once, as well:
C:\>ren *.txt *.rtfC:\>ren *.htm *.htmlC:\>ren *.mpeg *.mpg
Notes
The
renandrenamecommands are functionally identical.You can’t move files from on directory to another with
ren; usemoveinstead.The file’s Last Modified date is not changed when using
ren.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access