Skip to main content


Showing posts from February, 2011

Bulk rename files in Linux

Use the rename command :

To add the album title at the beginning :$ rename -v 's/^/TITLE-HERE-/' *.mp3

-v : verbose
s : substitute. it acts in the same way as regular expressions do in SED.

To replace a part of filename: $ rename -v 's/MISC\.\ -/Fossils-/' *.mp3

e.g. :-
MISC. - 01.mp3 to Fossils-01.mp3
MISC. - 02.mp3 to Fossils-02.mp3
MISC. - 03.mp3 to Fossils-03.mp3

To rename to lower case: $ rename 'y/A-Z/a-z/' *

To rename recursively: $ find ./ -type f -exec rename 'y/A-Z/a-z/' {} \;

Linux command : find

find & xargsPart of the reason why the Linux command line is so POWERFUL! Finding files can be a daunting task, given the vast number of files on your average Linux filesystem. The number of system files in an average Linux install is well into the tens of thousands, or even hundreds of thousands of files. That's not counting user files!
The command `find` is, as it's name implies, used to aid you in finding files you are looking for, anywhere in your filesystems. Plus much more (see below).

find can use a large number of other criteria to find a file.
The first argument to "find" is the directory (or directories) to perform the search. Example: find (and display) every file in your home directory: find $HOME"-name" the name of a file, or a partial name (basic regex). Example: find the file named "bookmarks.html" in your home directory: find $HOME -name bookmarks.htmlExample: find all files starting with the name "…