Rename is a changing the name of an object. For example, you could rename a file called “12345.txt” on a computer to “book.txt” so it can be identified without having to open and read its contents.

In the animated picture, you’ll see an example of how the file “logo.png” is renamed to “example.png” in Microsoft Windows. The file is right-clicked, then the rename option is selected from the context menu which appears.

How to rename a file from the command line

There are many ways to rename a file from a command line, and the command used depends on what command line you’re using.

While a file is highlighted in Windows, pressing F2 lets you rename.

If the file is set to read-only, is in use, or you don’t have permissions, you’ll get an error when trying to rename the file.

  • How to rename a file from the command line

  • How to rename a picture, folder, or another object

  • Can rename change the contents of a file?

  • See ren and rename command for renaming in the Windows command line (DOS).

  • See the Linux mv command and rename command for renaming a file in Linux and in the macOS Terminal.

  • To rename in an FTP command line, see: How to use FTP from a command line.

How to rename a picture, folder, or another object

Almost any object (e.g., document, folder, picture, or tab) with a name can be renamed. From a Graphical User Interface (GUI) like Microsoft Windows, you can rename by right-clicking the name and choosing the Rename option. If you are trying to rename from a command line, use one of the commands mentioned earlier.

Can rename change the contents of a file?

No. The rename command and function only rename the file name and does not edit or change the file’s contents. However, if the file name uses a file extension and it’s changed or removed, it changes the file association. For example, if the file was a Microsoft Word document named “hope.doc” and renamed to “hope.txt” in Windows Explorer. Microsoft Windows would attempt to open the file as a text file, which would not work because it was created in Microsoft Word.

If you have a document, picture, or another file open, it cannot be renamed because it is being used. However, you can choose the Save As option to save the file as a different name.

Label, Software terms

  • How to change or rename a file, folder, or directory.
  • How to quickly rename multiple files in Windows.
  • Create, delete, rename, copy, and move a worksheet in Excel.