Using Filebot to batch rename files

Filebot is a very useful cross-platform piece of software offering powerful batch processing features that can drastically speed up the chore of renaming your files so that they will match up to RockPeaks metadata. The program is available for different operating systems, their support is excellent, and a yearly license is a very reasonable $6.

Here’s an example of how to use Filebot to batch rename a series of files that have been ripped from a DVD and prepared according to the instructions in this forum post. If you’ve followed along successfully with those steps, you will have something like this:

After downloading Filebot, double click to open the program and you should see this:

The “Rename” function is selected by default, which is what we want. The first step is to drag a folder of files onto the “Original Files” window at left, like this:

Then click once on the “New Names” window at right to give it the focus. You’ll see a thin blue keyline around it which indicates it is active. Then press the F2 key on your keyboard - on the Mac, hold down fn and press F2 on the top row.

The program will attempt to rename the files using a custom format expression. If this is the first time you are using Filebot, you will probably see something like “Expression yields empty value” for all your filenames. Don’t worry, this is normal. Double click on the first file in the list and then click on the blue “Edit Format” link:

This will bring up a dialog box where you can paste in a custom Format Expression. What’s that you ask? Well, it is a chunk of code that uses regular expressions to parse, match patterns and rename strings of text. Don’t worry, you don’t need to know how it works. Just highlight the code below and copy it in to your paste buffer:

{
   def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
   def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
   def year = file.dir.name.match(/\d{4}/);
   def yearTrail = "(${year}|${year[2..3]})(?!.*(${year}|${year[2..3]}))";
   def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{1,2}/)?.pad(2)}{''};
   def show = file.dir.name.after(' - ').space(' ');
   def showTrail = [show.replaceAll(/\p{Punct}/, '.?').tokenize().reverse().inject{t, h -> "(($h ($t)?)|$t)" }, show.tokenize(',')*.trim()*.tokenize(' ')*.first().join('|'), show.acronym()].join('|');
   def title = any{fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))").replaceAll(/--\s/)}{fn.space(' ').before(yearTrail).after(artistHead).before("($showTrail)(?!.*($showTrail))")};

   [number, artist.reverse().join(' '), title?.pad(2), show, year].findAll{ it?.length() > 0 }.join(' -- ')
}

In the centre of the dialog box in Filebot you will see a white input field where you paste the code. if you want, you can expand the dialog by dragging out from the bottom corner so you can see more of the code field:

Click “Use Format” in the bottom right, and the dialog will close, and you’ll see that Filebot has replaced the filenames with much more useful text – everything but the song titles are now there, in the proper order, with the correct double hyphen delimiter. Press the blue arrow in the middle of the screen to actually execute the renaming action:

Sure enough, if you navigate to where the files are on your computer, you’ll see the results:

All that’s left to do is paste in the chapter titles, which you will have in a local text file, or out on a web page. There is an extra double hyphen before the old sequence number, so just highlight both and then paste in (or just type) the correct name of the chapter:

That is the basic process. When doing subsequent renames, the code you pasted in to Filebot will still be there, so all you’ll need to do is press F2 and the renaming will execute, making the process faster.

If you’d like to read more about using custom scripts with Filebot, this page is a good place to start.

For information on how to deal with Promo Videos, which need both a title and the correct show assigned, head over to this post.