forked from robinsloan/perfect-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.rb
More file actions
18 lines (12 loc) · 709 Bytes
/
convert.rb
File metadata and controls
18 lines (12 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require "shellwords"
# /Applications/calibre.app/Contents/MacOS/ebook-convert build/annabel-scheme-new-golden-gate/epub/annabel-scheme-new-golden-gate.epub annabel-scheme.azw3
Dir["build/epub/*epub"].each do |epub|
basename = epub.split("/").last
puts "Converting #{basename} to PDF"
pdf_name = epub.gsub(".epub", ".pdf")
`/Applications/calibre.app/Contents/MacOS/ebook-convert #{Shellwords.escape(epub)} #{Shellwords.escape(pdf_name)}`
puts "Converting #{basename} to mobi"
# Note: kindlegen doesn't want a path with the output filename
mobi_name = epub.split("/").last.gsub(".epub", ".mobi")
`./kindlegen #{Shellwords.escape(epub)} -c0 -verbose -o #{Shellwords.escape(mobi_name)}`
end