Skip to content

Instantly share code, notes, and snippets.

@sukria
Last active August 29, 2015 14:17
Show Gist options
  • Save sukria/48f99ce17b2623b8d533 to your computer and use it in GitHub Desktop.
Save sukria/48f99ce17b2623b8d533 to your computer and use it in GitHub Desktop.
epub to mobi converter
#!/usr/bin/env perl -W
use strict;
use warnings;
use File::Spec;
foreach (<*.epub>) {
my $epub_file = $_;
my $mobi_file = $epub_file;
$mobi_file =~ s/\.epub/\.mobi/;
print "\n\n*** ";
print("Converting $epub_file: ");
convert($epub_file, $mobi_file);
if (-r $mobi_file) {
print "OK\n";
}
else {
print STDERR "Error";
exit 10;
}
}
sub convert {
my $source = shift;
my $dest = shift;
my $parser = "/Applications/calibre.app/".
"Contents/MacOS/ebook-convert";
system($parser, $source, $dest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment