How to Rename Files Using Linux
A good number of Linux distributions come with a default file manager incorporated in the desktop environment. Generally, a desktop environment includes a window manager and maybe the following:
Panel (taskbar)MenuLaunch barDashboardWidgetsDesktop iconsTools (calculators, notepads, file managers)
A file manager helps you move, create and delete files. Some of the file managers include Dolphin, Nautilus, PCManFM, Thunar, and Caja. They are the default file managers in different Linux distributions.
Renaming a File Using a File Manager
When you look around the file manager you will see an icon that resembles a filing cabinet. Depending on the distribution you are using, you will find the file manager icon on a quick launch bar, on the menu system or on a panel in the launch bar. On the left panel of any file manager is a list of places such as other devices, the desktop, recycle bin, and the home folder.
The right panel contains the files and folders that are in the place you have selected on the left panel. The steps used to rename a file are the same regardless of the distribution, file manager, and desktop environment.
Right click on the folder or file you are interested in select “Rename”.
Renaming a File Using the Linux Command Line
This guide will teach you how to rename a part of the file, the complete file and the file that symbolic links point to.
Renaming a File
The syntax for this is not that obvious. This is the command for doing that:
rename expression replacement file
Why is the command not as simple as rename old file new file? Although it may not seem like it, the Linux rename command makes things very easy when you want to rename several files at once. If you have named several files wrongly (maybe used Mexico in the file names instead of France) you can rename them all at the same time:
rename Mexico France *
Renaming Files That Symbolic Links Point to
A symbolic link works like a desktop shortcut, pointing to a file. A symbolic link has no data; all it has is a path to the physical file.
To create a symbolic link, use the following command:
In –s
For instance, if there is a file named Eiffel Tower France in the France pictures folder, you can make a symbolic link to that file in another folder called vacation with the name Francevacation.
Use this command:
In –s ~/pictures/Francepictures/eiffeltowerFrance
~/pictures/vacation/Francevacation
If you run the Is –It command, you will see the symbolic links files.
Since the Eiffel tower is in Paris you can rename the eiffeltowerFrance picture to eiffeltowerParis using this command:
rename France Paris /home/pictures/Francepictures/eiffeltowerFrance
To rename using the symbolic link:
rename –s France Paris /home/pictures/vacation/Francevacation
To See If the Rename Has Worked
Use this command:
rename –v Mexico France *
You will see what has been renamed.
Another Method of Renaming Files
For those who prefer the simple way of doing things, here is an easy method for you. Use the mv command:
mv oldfilename newfilename


