Skip to content

RENAME command in Windows

The Windows rename command is a powerful tool for efficiently renaming files and directories in the Windows operating system. By using this command, users can easily change the names of multiple files at once, saving time and effort. The rename command allows for various renaming options, such as adding prefixes or suffixes, replacing text within file names, and even renaming files based on specific criteria. This command is especially useful for automating batch renaming tasks and organizing files in a more systematic manner.

Terminal window
rename [drive:][path]filename1 filename2
OptionDescription
No optionsThis command does not have any options.
ParameterDescription
drive:Specifies the drive containing the files to rename.
pathSpecifies the path to the file(s) that you want to rename.
filename1Specifies the current name of the file you want to rename.
filename2Specifies the new name for the file.
Terminal window
rename file.txt newfile.txt

Rename the file “file.txt” to “newfile.txt”.

Terminal window
rename folder1 folder2

Rename the folder “folder1” to “folder2”.

Terminal window
rename C:\folder1\file.txt C:\folder1\newfile.txt

Rename the file “file.txt” in folder “folder1” to “newfile.txt” while specifying the full path.

Terminal window
rename *.txt *.doc

Rename all files with the extension “.txt” to “.doc” in the current directory.

Terminal window
rename file1.txt file2.txt file3.txt

Rename multiple files in a sequential order - “file1.txt” becomes “file2.txt”, “file2.txt” becomes “file3.txt”, and so on.

Terminal window
rename "C:\folder with spaces\file.txt" "C:\folder with spaces\newfile.txt"

Rename a file located in a directory with spaces in its name.

Terminal window
rename newfile.txt file.txt

Revert renaming operation by renaming “newfile.txt” back to “file.txt”.

Terminal window
rename "C:\folder\hiddenfile.txt" newname.txt

Rename a hidden file located in a folder.

To use the rename command in Windows, execute the following command:

Terminal window
rename --option <value>

To use the rename command in Windows CMD, you can use the following syntax:

Terminal window
rename "oldfilename.txt" "newfilename.txt"

What is the purpose of the Windows CMD rename command?

Section titled “What is the purpose of the Windows CMD rename command?”

The rename command in Windows CMD is used to change the name of a file or directory.

Can I use wildcards with the Windows rename command?

Section titled “Can I use wildcards with the Windows rename command?”

Yes, you can use wildcards like * to rename multiple files that match a certain pattern. Here is an example:

Terminal window
rename *.txt *.md

How can I rename a directory in Windows using CMD?

Section titled “How can I rename a directory in Windows using CMD?”

To rename a directory in Windows using CMD, you can use the rename command with the directory paths. Here is an example:

Terminal window
rename "oldfolder" "newfolder"

Is it possible to rename a file extension in Windows CMD?

Section titled “Is it possible to rename a file extension in Windows CMD?”

Yes, you can rename a file extension using the rename command in Windows CMD. Here is an example:

Terminal window
rename "file.txt" "file.csv"

How can I force rename a file in Windows CMD?

Section titled “How can I force rename a file in Windows CMD?”

To force rename a file in Windows CMD without prompting for confirmation, you can use the /Y option. Here is an example:

Terminal window
rename /Y "oldfile.txt" "newfile.txt"

What should I do if the Windows CMD rename command fails?

Section titled “What should I do if the Windows CMD rename command fails?”

If the Windows CMD rename command fails, ensure that you have the necessary permissions to rename the file or directory. Check if the file is in use by another program before attempting to rename it.

How can I undo a rename operation in Windows CMD?

Section titled “How can I undo a rename operation in Windows CMD?”

To undo a rename operation in Windows CMD, you need to rename the file back to its original name. Make sure to use the correct source and target filenames when reverting the rename operation.

  • Renaming files
  • Renaming directories
  • Batch renaming multiple files or directories
  • Changing file extensions
  • Moving files to a different location while changing their names