Home Linux How to rename files in Linux

How to rename files in Linux

0
How to rename files in Linux

How to rename files in Linux

As simple as it seems, it might be as complicated. Renaming shouldn’t be any advanced option on any modern-day operating system, neither should it need the special tools. However, when there’re entire vacation photos or hundred of vlog clips waiting in queue to be renamed to do anything further with it, it might be wise to save some time and use these tricks. You could get in this situation any day.

For the batch rename of files, there are specific applications but you could also use the mighty Linux terminal to do the heavy lifting.

  1. With simple Move command

This is the simplest way to move the files, but this can also be used to rename the files and folders. The task of renaming functions as moving one file to another at the same location.

The following syntax is used:-

Mv filename1.ext filename2.ext

The following is a screenshot of renaming “abc.txt” to “xyz.log

That was on git on Windows, but it works exactly the same.

This same works when you have to move across folders.

I am in the text directory, and I want to move to the file “xyz.log” to test/a/xyz.log

  • mv xyz.log a/xyz.log

You must have write permission to wherever you’re moving. There is a -v flag to use for verbose (list changes after they’ve been made) and -i for the interactive approach (asks you before making changes). You can put the flags at the end or at the beginning of the commands.

  1. With “rename” command

This is an awesome command, except it requires some knowledge of regular expressions for the advanced usage. It might sound easy but there are whole books dedicated to regular expressions. It’s not tough, to begin with either.

This is what rename command looks like:

  • rename ‘s/oldname/newname’ file1.ext file24.ext

The “s” stands for substitute, The single quotes around it are mandatory! That is what makes it a regular expression.

The rename command can accept the wildcards:

  • rename ‘s\.jpeg/\.jpg/’ *

The wildcard * stands for anything. The regular expressions has options you can use such as “g” for global and “i” for case-insensitive substitution.

Using Dedicated Application Instead:

Are you afraid of the console, the dedicated renaming solutions come to rescue. Let’s look at pyRenamer.

You can install it on Ubuntu as:

sudo apt-get install pyrenamer

If you want to compile by yourself the forked and improved repository is available at https://github.com/SteveRyherd/pyRenamer.

pyRenamer is an application to change the names of several files at the same time. This fork currently includes renames based of file creation/modification dates, as well as improved removal of accent characters.

It needs python2, and you could follow the easy documentation on readme.md file for all actions possible with it.

It has a nice interface for convenient accessing.

The interface has four parts:-

  1. tree-view file browser for selecting
  2. preview pane showing before and after renaming
  3. control area for choosing the criteria
  4. the Options sidebar

How to rename files in Linux

pyRenamer can remove duplicate symbols and accents from filenames, replace any text or part of it with another, change filenames to lowercase, uppercase, or sentence case, and automatically remove or insert underscores and spaces. All this can simply be selected in the tabbed area, previewed in the main area and confirmed by clicking Rename. Beginners will love it. If they wish to experiment with patterns, pyRenamer provides a cheat sheet to make it easier.

You might also like to read this

How the Blockchain Works

How good is your internet security against Ransomware

Hope my article “How to rename files in Linux” helps you to rename files in Linux. if you have any query, feel free to comment.

Advertisements

LEAVE A REPLY

Please enter your comment!
Please enter your name here

one × 3 =