How to change or rename a file, folder, or directory
Below are steps on how you can rename a file or directory. Click on one of the links below to automatically navigate to the correct operating system.
Note: You must have write or modify permissions to a file, folder, or directory to rename it. In some cases, you may also need administrator privileges in the operating system to rename.
How to rename in Microsoft Windows
Windows users can rename their files and directories by using one of the below methods. We've listed the below recommendations in what we believe to be the easiest methods of renaming a file.
First recommendation
- Highlight the file or folder.
- Right-click the file and click Rename from the menu that appears.
Second recommendation
- Highlight the file or folder.
- Press the F2 key on the keyboard.
Third recommendation
- Highlight the file or folder.
- Click File at the top of the Window and select Rename from the list of available options.
Fourth recommendation
- Highlight the file or folder you want to rename by single-clicking the file.
- Once highlighted wait a few seconds and click the file again. A box should appear surrounding the file or folder name and you should be able to rename the file.
Note: If you don't wait long enough and click the file or folder too fast it can open the file or folder.
Renaming multiple files or folders at once
- Open Explorer.
- In Explorer select all the files you want to rename.
- Once the files have been selected press F2 and type the new name for the files. For example, typing "test" will rename the files to test, test(1), test(2), test(3) etc. If you have file extensions shown make sure to also type the name of the file extension you're renaming.
Microsoft Windows users can also rename any file using the Windows command line.
How to rename in MS-DOS and the Windows command line
MS-DOS and Windows command line users can change the name of a file or directory by using the ren or rename command. Below are some examples of how this command can be used. Additional information about each of these commands can be found by clicking the above command links.
Renaming a file
In the example below this would rename the file test.txt to hope.txt.
rename test.txt hope.txt
If the test.txt file was in a different directory then the one you were currently in you would need to specify the path of the file. For example, if the file was in the "computer" directory you would type a command similar to the example below.
rename c:\computer\test.txt hope.txt
Renaming a file with a space
Whenever dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise, you'll 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 example shown below.
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 some examples of how this could be done.
In the example below this would rename all the files in the current directory that end with .rtf to .txt files.
rename *.rtf *.txt
In this next example the command would rename a file with an unknown character in the file name to something that can be read. The "?" used in the example below 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 that have the same name you will not need to worry about mistakenly renaming a file instead of a directory, unless you're using wild characters.
In the example below this would rename the computer directory to hope.
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'll 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 by using one of the below methods. We've listed the below recommendations in what we believe to be the easiest methods of renaming a file.
First recommendation
In the macOS X Finder select the file by clicking the file once and then press the 'return' key on the keyboard. After pressing return you can type in 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 by using one of the below methods. We've listed the below recommendations in what we believe to be the easiest methods of renaming a file.
First recommendation
Highlight the file by clicking on the file once. Press Ctrl+Enter on the keyboard and then type the new name of the file.
Second recommendation
Right-click the file by pressing two fingers on the touchpad at the same time. In the right-click menu slick Rename and then type the new file name.
Additional information
- How to replace the file extensions of several files.
- See the file, folder and directory definitions for further information and related links.
