Last active
August 29, 2015 14:17
-
-
Save sukria/48f99ce17b2623b8d533 to your computer and use it in GitHub Desktop.
epub to mobi converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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