How to rename multiple files at once in Linux

rename

Renaming a file or directory is very simple, both from the terminal and from the graphical environment. It can be done in a number of ways, such as with the mv command or with cp. However, sometimes it is necessary to rename several files at the same time, and doing it one by one can be a big hassle, especially if there are too many.

In this tutorial you will see some forms of power rename files in one go in Linux in a simple way ...

Methods to rename files in one go in Linux

There are several forms of power rename multiple files one-time on Linux. Here are the best alternatives for it:

Use the manual (man) to get more information on these commands. I will only put an example of simple use. But they have many more options ...
  • mmv: is a command that can move, copy and rename files. It is available in the Debian and derivative repos, so you can install it easily. To use it, imagine that you have file1.txt, file2.txt and file3.txt and you want them to be called a1.txt, a2.txt and a3.txt, well, you would only have to go to the directory where those files are and execute this order:
mmv fichero\* a\#1

  • rename: is another utility to be able to change the name of the files. It can be easily installed from the repos and once installed, its use is simple. For example, suppose you have abc1.txt, abc2.txt, and abc3.txt and you want to rename them to xyz1.txt, xyz2.txt, and xyz3.txt. You just have to go to the directory where you have those files and execute:
rename 's/abc/xyz/' *
  • renameutils: is a suite of programs for renaming files and directories quickly and easily. It integrates qmv to move, qcp to copy, imv to move interactively, icp to copy interactively, and deurlname to remove URLs. Going back to the same previous examples, imagine that you have them in the test / directory, in that case, to rename them you must execute the following command, and that will open a text editor so that you can rename comfortably (in the left column are the names current and in a column to the right you can write the name you want to give each one):
qmv prueba/

  • vimv: it is based on the Vim text editor and works in a similar way to the previous one, being able to alter the names from the editor. That is, the names of the files in the directory will be listed in lines of the text file so that you can edit them, once you have edited them all as you want, when you save they will be modified. To handle the editor, it is the same as the famous text editor ... And by the way, if you are more into Emacs, it can also be done with it.
  • Thunar: this file manager is in several repos. If you install it, from it you can also quickly rename several files at once. It works similar to the editor method, that is, you can see a Name column with the current names and another New Name with the new names you want to put, and so you can rename in batches. When finished, press the Rename files button and that's it.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.