How to easily rename files in Linux with command line?

The Linux operating system is the most popular free software on the market today; This is because Linux has multiple versions and features. However, most people don't really know how to get the most out of it. Here's why this tutorial, so you can learn more about the penguin alternative, by answering How to rename files in Linux with command line?

If you think this process is very simple and you don't need any guidance, you are wrong, because even if it's not that complicated, it needs someone to tell you the steps to follow (it's not at all the same as the process you do when you rename or rename all files in Windows 10).



How to rename files in Linux with command line?

First of all, and before you start, read the steps that will help you solve the question , «How to rename files in Linux with the command line? You need to keep in mind that there are two commands you can perform this process with, and you will see them both below.

Number one is called mv, and although it was originally used to move objects, you can also rename them without any problems. In order to use it you must first open the Ubuntu terminal. To do this, you need to know which version of the Ubuntu system has been installed.

When you are there, type : mv (option) File1.ext File2.ext. The first file would be the old name and the second the replacement. Once you have put it with the names you want to put, you have to give Enter, which will automatically change things.

 

How to easily rename files in Linux with command line?


In the same way and with the same command you can change the name of a folder, you just have to specify its path, for example: mv /home/user/miracomo/file1.ext /home/user/miracomo /file2.ext.


Keep in mind that to make the change in a folder you will need write permissions, and if you want to rename a system file, you will need root permissions, you do this by putting the word sudo or su before mv.

If you want to change the extension of several files at the same time, you can use the combination: mv *.extensionActual *.extensionNueva, and voila, with that you can make the change you want within your command line.

Remember that you have to put the commands as they are, because otherwise there will be no effect and it will just give you an error, also consider not putting very crazy things as a name, because afterwards you will not even remember what is there.

Use the rename command

With what you read in the previous section, you can already tell that you know the answer to the question How to rename files in Linux with command line? , but now you need to see the second way to rename things with the terminal.

The command to use is rename and basically this allows the same as the previous one, but its advantage over the other is that it is more powerful and allows you to work with larger batches. To use it, the first thing you need to do is go to the terminal.


Once there write the command: sudo apt install rename, which will install it, so you just have to put it with this syntax rename (opzione) ‘s / old_name / new_name’ file1.ext file2.ext.

How to easily rename files in Linux with command line?

 

The letter S means substitute (as you will put the new names there as indicated), the inserted quotes are mandatory so do not remove them, just edit the names. In case you want to batch change file extensions, you should use: rename ‘s /.png /.jpg /’ *


Obviously you have to replace the extensions, but the * mark should be left, since that is the wildcard which means that everything inside the folder will be changed at the same time. With the last thing you read, you already know the basics of this command (at least what you need).


If you want to use other combinations of more complex level, you can search for the command name in the browser search bar, now you can go to your terminal to change whatever you want.

add a comment of How to easily rename files in Linux with command line?
Comment sent successfully! We will review it in the next few hours.