How to Rename a File in Linux

Are you new to Linux? To rename a file or directory in Linux, use one of these four ways. Renaming a file is one of the most straightforward computer tasks. In Windows, this is true, but in Linux, you must write a long list of commands to rename a file, directory, or folder. How to rename a file in Linux? Only if you are familiar with the appropriate commands will rename files on Linux may not be a problem. You can rename a file in Linux using either commands or a standalone application. Follow the steps below if you’re new to Linux and want to learn how to rename a file in Linux.

Also read how to zip and unzip files in Linux.

Ways to Rename Files in Linux

We can also rename files as well as directions in Linux. You may also check here.

  • Using the File Manager in Linux
  • Using pyRenamer application
  • By Using mv command
  • Using rename command

Method 1: Rename a File in Linux using File Manager

File Manager is built-in software that allows you to manage all the files on your computer. This procedure is quite similar to renaming files, directories, or folders on a Windows PC.

Step 1: Navigate to the file you wish to rename in the File Manager.

Step 2: Right-click the file and select Rename, or left-click and select F2.

Select Rename, or left-click and select F2
Select Rename, or left-click and select F2

3rd Step: Replace the old name with the new one. The user interface may be different. Dolphin and Caja allow you to write over the old name, however, Thunar and Nautilus require you to enter the new name in a tiny window.

You may rename a file or folder in three steps using the File Manager.

Method 2: Using pyRenamer application

In Linux, pyRenamer is the finest application for renaming files. It is the finest technique to rename files for a newbie. If you wish to install the pyRenamer app on your Linux PC, go to http://bit.ly/2MzpKm5 and download it.

The pyRenamer application includes four different user interfaces.

  1. A view type for selecting files and directories on the left side of the screen (similar to Windows PC)
  2. A preview pane in the center shows the original and renamed filenames.
  3. Tab for inserting the old and new names is located on the bottom side.
  4. There is an Options bar on the right side.
Four Methods to rename file in a Linux

Patterns, Substitutions (Find and Replace in Windows), Insert / Delete, Manual Rename, Images, and Music are just a few of the renaming possibilities available in pyRenamer. If you have any uncertainties, simply hover your cursor over the option, and a brief description of the option will appear.

Step 1: Using the branch view interface, select any of the files you want to rename.

Step 2: After selecting the file, go to the Manual rename tab and input the new name in the New file name field.

3rd Step: To see what changes you’ve made, click Preview.

Step 4: In the preview pane, take a look at the new names. If you wish to make some modifications, go ahead and do so. Click the Rename button if you’re happy with it.

All the files you chose will now be renamed. Stick to the pyRenamer app if you’re new to Linux. If you’d want to test out some alternative renaming tools, KRename and Metamorphose2 are two independent options.

These are two approaches that do not require the use of the CLI (Command Line Interface). Stick with these two ways if you don’t want to go into the coding process. Instead, if you want to learn how to code, use the other two options.

Method 3: By Using mv command

The mv command is used to move files and folders as well as rename them. In Linux, using commands is comparable to using the Command Prompt on a Windows PC. The mv command is the most straightforward way to rename files under Linux.

mv oldname newname

The mv command’s syntax is as follows. This syntax is used to rename folders and directories. If you wish to rename a file that isn’t in the active folder, type the complete path or navigate to the folder where the file is located.

Method 4: Rename files in Linux using the Rename Command

The rename command is more complicated than the mv command since it requires knowledge of regular expression in Linux. But it’s not out of the question. You can only rename one file with the mv command. The rename command is used to rename multiple files.

rename ‘s/oldname/newname/’

The rename command’s syntax is seen above. s stands for substitution, and single quotes are standard.

Aside from s, there are many other options available in Linux.

  • -n: “no action.” A preview mode that allows you to see the changes without altering the actual document.
  • -v: “verbose”. It will print a list of altered files that includes the most current updates.
  • -f : “forced.” An unintentional overwrite of the original files
  • -y: “Complex Charges” This suffix is used to change the case of letters.
Four Methods: How to Rename a File in Linux

You can alter the format of a single file or several files with the rename command. As an example,

rename ‘s/.tiff/.png/’

The program above will convert all TIFF files to PNG files. The rename command allows you to make some modifications.

rename ‘y/A-Z/a-z/’

This command converts all uppercase to lowercase letters in all files.

If you know the following commands, the rename command is the best and easiest way to rename a file.

Conclusion: How to Rename a File in Linux

The four methods for renaming files and folders on Linux OS PCs are as follows. If you’re not a fan of coding, try using the first two ways to rename all of your files. Put your code abilities together and try out the last two methods if you’re a coding hoodie person. If you know of any alternative ways to rename a file or folder on Linux, please let us know in the comments area.

If you have queries or feedback, tell us through the comment section below. To get regular updates, follow us on Twitter and Facebook.

Leave a Reply