There are several ways one can batch rename files in Linux. One of the possibilities is the linux command rename.

Usage

To rename files you have to supply a Perl expression. Using Perl expressions might be scary for beginners (because they look like someone hit his head on the keyboard), but they allow for complex renaming with a minimum of characters.

Although I won’t go into detail about Perl expressions here, I will try to make it a little easier for beginners to use them for batch renaming.

According to the man page of rename, this is the way to use rename:

rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

If you have not worked with Perl expressions before, this might not be enough to get you started. So let me present you with the way one would probably use rename most of the time:

rename 's/OLD/NEW/' FILES

OLD is an expressions which describes a pattern in the name filenames. If rename can find this pattern in the name of a file, it will replace this part of the filename with what is defined as NEW. The files rename should rename are defined by FILES.

Let me provide you with two examples: Continue reading »

 

The Linux command mkdir (make directory/make directories) can be used to create new directories.

Basic Usage

Creating directories in the current working directory

The most basic usage of mkdir is the following:

mkdir <name>

This will create a new directory with the given name in the current directory. Therefore, if your username is “me” and in the terminal you are using you are currently in your home folder (/home/me) then running the command

mkdir backup

will create a the directory /home/me/backup.

Continue reading »