304 North Cardinal St.
Dorchester Center, MA 02124
If you have just started working with Linux, you might land up with the question, how to rename a file in Linux? This guide has examples using terminal / command-line and GUI tools.
There are just two ways to rename files and directories in Linux. One being the terminal way using
mv command, whereas other method includes using a GUI tool.
There is no dedicated command in Linux for renaming files and folders.
The problem with
mvcommand is that you cannot use it to rename multiple files or folders in one shot. You might have to do it individually for each file and folder. Which is obviously not a great idea.
Fortunately, the Linux community is so great they have some or the other terminal commands ready to tackle a problem. So if you want to rename all those pictures from last year’s Christmas, we have got you back.
[su_label type=”success”]Suggested read[/su_label] Do you face issues downloading files in Linux ? Here are the few best ubuntu downloaders.
Let’s see quickly how can we achieve a solution to the problem.
The very basic and easiest way to rename a file in Linux is to use
mvcommand without any additional flags or complexity.
Even though the primary purpose of the command is to move files and folders, it serves the purpose of renaming also very well. This is because OS interprets the operation of renaming as moving files from one folder to another.
Syntax to rename files :
mv source_file_name dest_file_name
mv myfile.txt myRenamedFile.txt
Syntax to rename directories :
mv source_dir_name dest_dir_name
mv myfolder myRenamedFolder
There are some options which can be very useful while using
mv command. Few of them are :
-vflag: It prints verbose output, as in log of all operation that are performed during
mv -v myfile.txt myRenamedFile.txt
‘myfile.txt’ -> ‘myRenamedFile.txt’
-iflag: This will prompt you before overwriting any existing file if it exists. This helps prevent data corruption for the already existing files.
mv -i myfile.txt myRenamedFile.txt
mv: overwrite ‘myRenamedFile.txt’? y
To see other options available with
mvcom4 mand, you can use the below command and it should help.
[su_label type=”success”]Suggested read[/su_label] If you are a Linux geek, you might be interested in Understanding syslog, rsyslog, syslog-ng, journalctl.
There are ‘n’ numbers of tools out there for achieving the purpose of renaming files in Linux. Today we will be talking about one such tool.
Métamorphose is a file and folder renamer tool that is widely supported across many platforms.
There many people who still prefer GUI tools even on Linux or Mac OS to do most of their operations. Tool is specifically targeted for them. Métamorphose is quite a powerful tool that can be used.
Head to its website and download the installer package based on your Linux distro. You get an option to download a
.debpackage for Debian based distros whereas
.rpmpackage for Fedora, Mandriva, and SUSE.
After downloading just run the app package and then follow the steps provided below.
[su_label type=”success”]Suggested read[/su_label] Have a look at our Linux ls command usage guide.
I hope this would have helped you rename files and folders. Let us know if there are some other ways to achieve the same.