Below are steps on how you can rename a file, shortcut, or directory. Click one of the following links to automatically navigate to the correct operating system.
How to rename in Microsoft Windows
Windows users can rename their files and directories using one of the following methods. We’ve listed the following recommendations in what we believe to be the easiest methods of renaming a file. These methods work for most types of files, including text, photos, documents, and others.
You must have write or modify permissions to a file, folder, or directory to rename it. In some cases, you may need administrator privileges in the operating system to rename.
- Microsoft Windows
- MS-DOS and Windows command line.
- Rename in a batch file.
- macOS
- Linux and Unix.
- Google Chrome OS.
- How to rename a document in Word or Excel.
Method one
- Highlight the file or folder.
- Right-click the file with your mouse and select Rename from the menu that appears.
Method two
- Highlight the file or folder.
- Press F2 on the keyboard.
Method three
- Highlight the file or folder.
- Click File at the top of the window and select Rename from the list of available options.
Method four
- Highlight the file or folder.
- Once highlighted, wait a few seconds and click the file name again. A box should appear surrounding the file or folder name, and you can rename the file.
Renaming multiple files or folders at once
Open Explorer.
In Explorer, select all the files you want to rename.
How to select or highlight multiple files and folders.
Once the files are selected, press F2 to edit the file name and type the new name for the files. For example, typing “test” renames the files to test, test(1), test(2), test(3), etc. If you have file extensions displayed, make sure to also type the name of the file extension.
Microsoft Windows users can also rename any file using the Windows command line.
This also works for removing spaces in a file name.
Renaming a folder containing files may cause problems if that folder contains files that are required by a program. For example, if the program is looking for a folder named “data” and you rename it to “other” the program would no longer know where data files are located.
In Windows 11, select Show more options in the right-click menu to see the Rename option.
File Explorer in Windows 11 does not have a file menu like previous versions of Windows. Instead, click the Rename icon in the menu bar at the top.
If you don’t wait long enough and click the file or folder too fast, it can open it rather than allowing you to rename it.
How to rename in MS-DOS and the Windows command line
MS-DOS and Windows command (CMD) line users can change the name of a file or directory using the ren or rename command. Below are examples of how this command can be used. Additional information about these commands is found by clicking the command links above.
- How to get to an MS-DOS prompt or Windows command line.
Renaming a file
The following example renames the file test.txt to hope.txt.
rename test.txt hope.txt
If the test.txt file is not located in your current directory, you must specify the file’s path as a prefix to the file name. For example, if the file is in the “computer” directory, type a command similar to the following example.
rename c:\computer\test.txt hope.txt
Renaming a file with a space
If a file or directory has a space, it must be surrounded with quotes. Otherwise, you get the “The syntax of the command is incorrect” error. To rename the file “computer hope.txt” to “example file.txt”, your command would resemble the following example.
rename “computer hope.txt” “example file.txt”
Renaming multiple files with one command
To rename multiple files at once, you must utilize some form of wild character. Below are examples of how this could be done.
The following example renames all the files in the current directory that end with .rtf to .txt files.
rename *.rtf *.txt
In this next example, the command renames a file with an unknown character in the file name to something that can be read. The “?” used in the following example is the wild character for an unknown character.
rename h?pe.txt hope.txt
Renaming a directory
Renaming a directory in MS-DOS is much like renaming a file. Use the ren or rename command to rename the directory. Because you cannot have a file and directory of the same name, you don’t need to worry about mistakenly renaming a file instead of a directory. The only exception is if you’re using wild characters.
The following example renames the computer directory to hope.
Renaming a directory containing files may cause problems if that directory contains files required by a program. For example, if the program is looking for a directory named “data” and you rename it to “other,” the program would no longer know where data files are located.
rename computer hope
Rename the directory “computer hope” to “example directory”. Whenever dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise, you get the “The syntax of the command is incorrect” error.
rename “computer hope” “example directory”
Rename in a batch file
To rename files in a batch file, you can use any of the rename commands or examples shown in the MS-DOS and Windows command line section.
How to rename in macOS
Apple macOS users can rename their files and directories using one of the following methods. We’ve listed the following recommendations in what we believe to be the easiest methods of renaming a file.
First recommendation
In the macOS Finder, select the file by clicking the file once and then press return on the keyboard. After pressing return, type the new name of the file.
Second recommendation
Select the file or icon you want to rename. Click and then hover over the file name until it is highlighted. Once highlighted, this indicates the file can be renamed.
Third recommendation
Using the Terminal, you can also rename any file. See our Linux and Unix users section for steps on renaming a file using the mv command.
How to rename in the Linux and Unix command line
For detailed information about renaming files in Linux, see the Linux mv command.
How to rename in Google Chrome OS
With the Google Chrome OS on a Chromebook, you can rename your files and directories using one of the following methods. We’ve listed the following recommendations in what we believe to be the easiest methods of renaming a file.
Highlight the file by clicking the file once. Press Ctrl+Enter on the keyboard and then type the new name of the file.
Right-click the file by pressing two fingers on the touchpad at the same time. In the right-click menu, click Rename and then type the new file name.
How to rename a document in Word or Excel
- Open the document you want to rename.
- Click File, then click Save As.
- In the Filename box, type the new name.
- Click Save. At this point, you can delete the old file or keep it as a backup.
Related information
- How to replace the file extensions of several files.
- How to create a directory or folder.
- How to delete a file, directory, or folder.
- How to change the icon of a folder in Windows.
- See the file, folder, and directory definitions for further information and related links.
- Computer file help and support.