How to Rename a File in Linux

Bertel King 29-01-2019

Want to rename a file in Linux? If you know how to do the job in Windows, macOS, or Chrome OS, then you know how to do it here. On most versions of Linux, all you have to do is right-click on a file and select the Rename option.



But that’s just the beginning. Renaming files in Linux may be easier and more powerful than you think. And you don’t have to dive into the command line to start having fun. There’s plenty of functionality built into your default file manager.

Renaming Files With Your Linux File Manager

Renaming files on the GNOME Linux desktop

If you have a semester worth of notes or folders filled with vacation photos, renaming files one at a time will take all day. Fortunately you don’t have to, and you may not even need to install additional software to make the job easier.

If you use the standard version of Ubuntu Ubuntu: A Beginner's Guide Curious about Ubuntu, but not sure where to start? Everything you could possibly need to get started with the latest version of Ubuntu is right here, written in easy-to-understand, plain English. Read More or Fedora, two popular forms of Linux, then the desktop interface you see is known as GNOME. In GNOME, you can rename multiple files at once by dragging your cursor over all of them, right-clicking on your mouse or touchpad, and selecting Rename. Then you will see the options to rename files using a template or by swapping out strings of text.


While GNOME is currently the most popular Linux desktop interface, there are many others. Whether you can rename multiple files at once, and how, may vary.

If you find you prefer KDE’s or Xfce’s file manager (Dolphin and Thunar), you’re also free to swap them in without switching desktops entirely.

Renaming Files With pyRenamer

Renaming files on Linux using pyRenamer

Depending on your needs, you may need a more advanced program. pyRenamer is a desktop agnostic tool that will spare you from having to dip into the command line.


Want to rename all of your photos according to date and time? Like to include the artist, album, and track title in the name of each MP3 file? Want to sort your papers by semester and course? This is the kind of app you want to download.

When you open pyRenamer, you will see a navigation pane on the left for browsing folders and a pane on the right for selecting files. The latter will show how your files look both before and after renaming. An options panel to the right of that lets you keep file extensions and preview changes automatically.

The magic happens at the bottom. There you enter the name pattern you want to see. Hover your cursor over the text fields to see which patterns you can use. Options include numbers, creation date, time, image metadata, and audio tags.

You can save patterns once you’re done by clicking the Save icon next to each field. The adjacent icon lets you open existing patterns, so you don’t have to remember the complicated formulas you use for your photos and music.


You can install pyRenamer on Ubuntu and many Ubuntu-based desktops by opening a terminal and typing the following command:

sudo apt-get install pyrenamer

Download: pyRenamer

Renaming Files With KRename

The KRename file renaming app displaying available plugins

pyRenamer will suit most Linux desktops just fine. Yet if you use the KDE Plasma desktop, you may prefer an app written in the Qt programming language instead. Such software tends to better integrate with the rest of the interface.


In that case, check out KRename. It’s similar in functionality to pyRenamer, only with a tabbed interface that you might consider easier to navigate.

KRename’s power comes from plugins, which occupy the third tab. You can enable more advanced features, such as the ability to transliterate file names from another language into English. Thanks to how well KDE programs integrate with each other, you can easily access KRename from Dolphin, the default file manager.

You can install KRename on Ubuntu and many Ubuntu-based desktops by opening a terminal and typing the following command:

sudo apt-get install krename

Download: KRename

How to Rename a File in the Terminal

The terminal can seem intimidating, but it comes with many benefits. Terminal commands are typically the same across different versions of Linux. The following rename commands work regardless of your chosen Linux desktop operating system or desktop environment. It also works on servers without any desktop at all.

There are two core commands that make short work of renaming files. The easiest option isn’t exactly obvious, so let’s tackle it first.

Rename files Using Linux’s ‘mv’ Command

The mv command is the shortest and simplest way to rename files in the terminal. Yes, mv is short for move, and moving files around is primarily what this command is for. To mentally associate mv with renaming, think of it this way: you’re technically moving data from one filename to another. Check out the example below.

mv /home/user/Downloads/old-file-name /home/user/Downloads/new-file-name

Alternatively, you can open or direct the terminal to the folder containing the file.

cd /home/user/Downloads/
mv old-file-name new-file-name

Note: If you actually want to move files using the mv command, rather than entering a new file name, type a target directory instead.

mv /home/user/Downloads/old-file-name /home/user/Documents/

Rename files Using Linux’s ‘rename’ Command

When the time comes to rename multiple files, the command quickly becomes tedious. For that job, you want the rename command instead.

Let’s say you have a bunch of text files (TXT) you wish to turn into Markdown files (MD). First, as in the example above, use the cd command to get to the relevant folder (alternatively, you may be able to use Right-Click > Open in Terminal). Then, enter the following command:

rename .txt .md *

The * tells the command to search all files in the folder. You could explicitly limit the search to files that end in .txt by modifying the command as follows.

rename .txt .md *.txt

The commands above won’t tell you what changes the rename command made. You have to open the folder and check for yourself. If you want confirmation inside the terminal, you can add the -v to the command.

rename -v .txt .md *

Technically, you can use the rename command to rename a single file. You just have to do more typing than you would with mv. For example:

rename old-file-name new-file-name old-file-name

Repeating the original file name at the end, rather than using an *, informs the command to only take action on this one specific file.

How Do You Manage Files on Linux?

Now you know how to rename files using your file manager and the command line. What about other file-related tasks?

Turns out, the terminal can replace your file manager. It presents a quick way to list, move, delete, copy, and paste the data on your computer. So if you’re ready to step up your file management game, let’s move on to how to manage files on Linux How to Manage Files in the Linux Terminal and Desktop Once you make the change to Linux, you'll find a sensible desktop that is easy to use, from installing new apps and launching them to organizing your data. Read More .

Image Credit: Naypong/Depositphotos

Related topics: File Management, Rename Files.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *