How do I change the name of a file or folder?

Below is additional information about how a user can rename a file or directory in their operating system. Click on one of the below links to automatically scroll to the operating system you need help with.

MS-DOS and Windows command line users
Microsoft Windows users
Linux and Unix users
Additional Information

MS-DOS and Windows command line users

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 below example 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 below example.

rename c:\computer\test.txt hope.txt

Rename the file "computer hope.txt" to "example file.txt". 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.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 below example 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 below 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 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 below example 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"

Microsoft Windows users

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

  1. Highlight the file or folder you wish to rename.
  2. Right-click the file and click Rename from the menu that appears.

Second recommendation

  1. Highlight the file or folder you wish to rename.
  2. Press the F2 key on the keyboard.

Third recommendation

  1. Highlight the file or folder you wish to rename.
  2. Click File at the top of the Window and select Rename from the list of available options.

Fourth recommendation

  1. Highlight the file or folder you wish to rename by single-clicking the file.
  2. 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 to fast it will open the file or folder.

Renaming multiple files or folders at once

  1. Open Explorer.
  2. In Explorer select all the files you wish to rename.
  3. 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 used the steps mentioned above MS-DOS section to rename their files and directories in the Windows command line.

Linux and Unix users

Linux and Unix users can rename their files and directories by using the mv command. Below are some additional examples of how this command can be used. Additional information about this command can also be found on the above command link.

Renaming a file

In the below example this would rename the file test.txt to hope.txt.

mv 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 below example.

mv computer/test.txt hope.txt

If the file that has a space within it either surround it with quotes or use a backslash. Below are two examples, the first using the backslash in front of the space and the second using quotes.

mv computer\ hope.txt computer_hope.txt

mv "computer hope.txt" computer_hope.txt

Renaming multiple files or directories at once

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 below example this would rename all the files in the current directory that end with .rtf to .txt files.

mv *.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 below example is the wild character for an unknown character.

mv h?pe.txt hope.txt

Renaming a directory

Renaming a directory in Linux and Unix is much like renaming a file replace the file name with the directory name that you wish to rename. For example, if we wanted to rename the directory "test" to "hope" you would type the below command.

mv test hope

Additional information