Convert folder of epubs to mobi with ebook-convert


So I wanted to convert all my epubs to mobi files for my Kindle without having to use the graphical Calibre software. Turns out, contained within the application package for Calibre on my Mac, there's a brilliant little utility called ebook-convert.

The application

% cd /Applications/
% ./ebook-convert source.epub
% echo The Bird is The Word

Looking at the help files, it appears it supports many different formats, not just epub. It also determines what file type to export based on the extension you provide.

The application of the application

With this in mind, you could write any number of shell or awk scripts to convert a bunch of epub files to mobi based on any criteria you so wished.

Perl remains my favourite Swiss Army Chainsaw, so I wrote a script to convert each epub in the current folder, and is flexible enough that I can change it later. I'm a fan of clear reusability :)

#!/usr/bin/env perl -W
use strict;
use warnings;
my $parser = "/Applications/".
foreach my $mobi (<*.epub>) {
	$mobi =~ s/.epub/.mobi/;
	print("CONVERTING $mobi\n");
	system("$parser '$_' '$mobi'");

Author bio and support


Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!