How to Rename Multiple Files in Linux At Once?

When you have a lot of files to manage, it makes sense to maintain a good naming convention. So how can you rename multiple files in Linux? Let’s look at the different ways to bulk rename files using the command line and graphical tools.

Rename Multiple Files in Linux with Command Line

There are multiple methods we can use to rename multiple files in Linux in a single go. If the filenames have any specific pattern, the renaming becomes very easy. Let’s have a look at two examples.

1. Using the rename command

The most commonly used Linux command-line utility for renaming files in bulk is the rename utility. To use the rename command, we install it on our system using this command.

sudo apt install rename

Once the utility is installed, we can now use the rename command through the command-line. This is what the syntax of the rename command looks like.

rename [Options] 's/oldname/newname/' *

This command requires basic knowledge of regular expressions. Here, ‘s’ stands for substitute. The remaining expression is self-explanatory. Using * makes the command run for all files whose name contains <oldname>.

2. Using renameutils

The renameutils package provides us with a set of commands to rename a file in Linux. With a focus on batch renaming of files, renameutils consists of five commands. For the purpose of this tutorial, we’ll only work with one of those commands – qmv which stands for Quick move.

To install renameutils on our system, we use the following apt command.

sudo apt install renameutils

Once the utility is installed, we can now use the qmv and imv commands through the command-line.

Quick Move (qmv) Syntax:

qmv directoryname/

This will open a window where the left column displays the original names of the files. Whereas, the right column is for the name which you wish to set for your files. Edit the right column to set the names you wish for your file.

Rename Multiple Files in Linux with GUI

If you’re not a command line person, we have you covered. For Ubuntu, and pretty much any other distribution, you can use

1. Using the Thunar file manager

Not everyone likes to use the command line for every task. So we have some great GUI tools to help us rename multiple files. Thunar has a built-in bulk rename tool that works really efficiently if you’re not a CLI person.

sudo apt install thunar

Now you can launch the bulk rename utility using the following command.

thunar -B
Bulk Rename Files
Bulk Rename Files

This is what the bulk renamer looks like. You can click the + sign to add files. It allows the following criteria for renaming.

  • Append Date/Time
  • Insert or Overwrite
  • Append numbers
  • Eliminate characters
  • Search/Replace
  • Switch character case

Once you choose the desired criteria, simply click Rename Files to proceed with the operation. The Thunar bulk renamer is popularly the best tool for renaming multiple files using a GUI file manager.

2. Using the pyRenamer tool

This is another really popular tool among photographers and musicians who also use Linux a lot. The reason being that pyRenamer can read EXIF data and automatically rename based on the date/time, camera model, and other metadata from the image files.

Since the utility was discontinued in 2008, and you may not be able to download it from the official repositories, but it still works perfectly fine for our task.

wget -c https://launchpad.net/ubuntu/+source/pyrenamer/0.6.0-1.2/+build/8439869/+files/pyrenamer_0.6.0-1.2_all.deb
sudo dpkg - i pyrenamer_0.6.0-1.2_all.deb

Alternatively, you can visit Ubuntu’s Pyrenamer package page and download the pyrenamer_0.6.0.orig.tar.gz file listed at the bottom. You then need to use the tar command to extract the package and install it.

PyRenamer Bulk Rename Files
PyRenamer Bulk Rename Files

This is what the pyRenamer tool looks like. While it doesn’t offer a wide range of options like the Thunar bulk renamer, it allows the following criteria for renaming.

  • Insert or delete characters
  • Patterns
  • Substitution
  • Music
  • Images

Once you choose the desired criteria, simply click Rename Files to proceed with the operation. The pyRenamer does what it promises, and does so really well. The one caveat to using this utility is the non-existent support.

Conclusion

Some other packages that allow bulk renaming are grprename and renrot (which also supports EXIF data).

Linux based systems offer a wide variety of options to rename a file in Linux. One can use any of these to suit their needs and preferences. We hope this tutorial was able to help you understand different ways to rename a file in Linux. If you have any feedback, queries or suggestions, feel free to leave them in the comments below.