Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 12-11-2018, 04:40 PM   #1
EmilThelonius
Enthusiast
EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.
 
Posts: 37
Karma: 71294
Join Date: May 2016
Device: Sony DPT-RP1 and Pocketbook Touch Lux 2 and Basic
[MacOS] Help, using shell script and ebook-convert, hazel

Hi Calibre-Community,

I have a question about using the ebook-convert program from calibre in a shell script – as I am a total noob to shell scrips, maybe someone here can help me? I am eager to learn and would be very thankful!

So I am using hazel on a mac to automate certain folders. Within one of the folders I want to have an automatic conversion from ePub to pdf. I stumbled over a very useful shell script in the internet, which can be used directly in hazel:
https://jake.ch/2013/03/03/hazelbooks/


Code:
FULL_PATH="$1"
ORIG_FILE=$(basename "$FULL_PATH")
/Applications/Calibre.app/Contents/MacOS/ebook-convert "$ORIG_FILE" "converted/$(basename "$FULL_PATH" .epub).pdf"
This works pretty well: it makes a pdf and puts it in a "convert" folder. But now I want to tweak the PDF to a certain size, add page numbers, set margins etc...

So I found the commands for the ebook-convert app from calibre:
https://manual.calibre-ebook.com/gen...output-options

But how can I include for example
Code:
--custom-size
to the shell script above? And how do I set the hight and the width?

EmilThelonius is offline   Reply With Quote
Old 12-11-2018, 08:19 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
you simply add options to the end of the command line in the script

and if your want to change page size, IIRC the option is named --pdf-page-size

run ebook-convert file.epub .pdf --help

in terminal.app to get help on all the available options.
kovidgoyal is online now   Reply With Quote
Advert
Old 12-12-2018, 05:15 AM   #3
EmilThelonius
Enthusiast
EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.
 
Posts: 37
Karma: 71294
Join Date: May 2016
Device: Sony DPT-RP1 and Pocketbook Touch Lux 2 and Basic
Thank you for your quick reply!

I got this in the log from hazel:
Code:
command not found
So I figured I need to install the calibre command line tools in MacOS –*but I cannot figure out, how to do that. I am in MacOsX Mojave –*maybe the system is to protected?

Is it possible to install the arguments without turning Off Rootless System Integrity Protection of MacOsX Mojave?

EmilThelonius is offline   Reply With Quote
Old 12-12-2018, 06:08 AM   #4
EmilThelonius
Enthusiast
EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.EmilThelonius knows who John Galt is.
 
Posts: 37
Karma: 71294
Join Date: May 2016
Device: Sony DPT-RP1 and Pocketbook Touch Lux 2 and Basic
Ah, I have got it –*but I am not sure what did the trick.
I downloaded the Xcode Command Line Tools from the apple developers page. Then I used the terminal phrase from this threat:
https://www.mobileread.com/forums/sh...d.php?t=264945

Quote:
Originally Posted by eschwartz View Post
The command-line tools are installed to your system PATH on Windows and linux, but not on OSX -- because OSX uses Bundles, which have no way to trigger post-install commands I believe.

There used to be an option in Preferences to symlink the tools into /usr/bin on OSX (like the linux installer does) but apparently the method used to get root privileges was deprecated a while back.


The solution is to manually symlink them:
Code:
sudo ln -sf /Applications/calibre.app/Contents/console.app/Contents/MacOS/* /usr/local/bin/

Note: My auto-upgrade script does this automatically. See here: https://github.com/eli-schwartz/calibre-installer
Note2: I don't use OSX, I experimentally ported it from the linux script which I do use, but I have received confirmation that it works as expected on OSX.


EDIT: Changed to accommodate System Integrity Protection, introduced in El Capitan.
Now I can use the command line tools from calibre – its magic I love calibre!
I will write a full workflow with Hazel and Shell Script this evening in here! Thanks for your help!
EmilThelonius is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to search all the libraries loviedovie Development 0 02-17-2015 10:12 AM
Shell Script Kindle 4nt nixlos Kindle Developer's Corner 3 08-12-2014 12:46 PM
invoking sql in a shell script Mingyar Kobo Developer's Corner 17 05-31-2013 06:50 PM
pdf to txt shell script Mr.Castro0o PDF 0 03-27-2013 07:39 AM
Perl script for ebook-convert gucky Calibre 3 01-11-2011 12:51 PM


All times are GMT -4. The time now is 09:30 PM.


MobileRead.com is a privately owned, operated and funded community.