05-29-2012, 06:51 PM | #1 |
Junior Member
Posts: 3
Karma: 10
Join Date: May 2012
Device: iPad
|
Scripting ebook-convert for batch parallel processing?
Hi! First post here. I'm interested in using the bash shell to script the conversion of my epub files to mobi. Right now I have this working:
Code:
for f in *.epub; do ebook-convert "$f" "`basename "$f" .epub`.mobi"; done; Thanks for any suggestions, Joe p.s. I'm on Mac OS X 10.7.4, using Calibre 0.8.53. |
05-29-2012, 07:18 PM | #2 |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Welcome to Mobileread.
Moderator Notice
Moved thread out of development sub-forum. Read this sticky post before posting again in the development sub-forum. |
Advert | |
|
05-29-2012, 07:51 PM | #3 |
Junior Member
Posts: 3
Karma: 10
Join Date: May 2012
Device: iPad
|
@dwanthny: Thanks for putting my question in the right sub-forum!
I look forward to any ideas people here in the Conversion sub-forum might have. |
05-30-2012, 12:33 AM | #4 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Bash is so last century Save the following as batch.py in the directory wth your epub files. Then run it as either
python batch.py or calibre-debug -e batch.py Code:
#!/usr/bin/python import os, time, glob, subprocess files = glob.glob('*.epub') workers = [] while files or workers: while len(workers) < 4 and files: f = files[0] files = files[1:] w = subprocess.Popen(['ebook-convert', f, os.path.splitext(f)[0]+'.mobi']) workers.append(w) for w in list(workers): if w.poll() is not None: workers.remove(w) time.sleep(0.1) Last edited by kovidgoyal; 05-30-2012 at 04:29 AM. |
05-30-2012, 08:13 PM | #5 |
Junior Member
Posts: 3
Karma: 10
Join Date: May 2012
Device: iPad
|
|
Advert | |
|
05-30-2012, 08:35 PM | #6 |
Enthusiast
Posts: 27
Karma: 10
Join Date: May 2012
Device: iPad
|
Joewiz, Don't believe him. Bash is still now!
Jump over to here: https://www.mobileread.com/forums/sho...124219&page=17 At the bottom of the page is a chunk of script which I happened to post earlier today (well, it's still Wed. here). Pure bash setup with a call to ebook-convert and all of the command line switches available. For *multi* use, I suppose you could open another terminal, and start another thread there. It *should* work...but that could depend on how your OS provides library (.so) access to calling processes. I have an idea that the memory space for running processes is kept separate. But MMMV. (I'm going to try it just to see). Otherwise, you will need to split your source files: can't have two 'for file in *;' processes looking at the same folder! |
05-30-2012, 09:27 PM | #7 |
Grand Sorcerer
Posts: 12,172
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
|
I'm willing to bet xpath could also be used with the --max-procs=4 parameter...
|
06-12-2012, 01:03 PM | #8 | |
hopeless n00b
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
|
|
06-12-2012, 11:38 PM | #9 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, it should work in windows.
|
03-15-2013, 05:34 AM | #10 |
Junior Member
Posts: 1
Karma: 10
Join Date: Mar 2013
Device: kindle
|
HI will this also scan sub directory's too ?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Batch breaks after ebook-convert.exe | j0s3f | Calibre | 1 | 05-04-2011 05:27 PM |
How to batch-convert with ebook-convert? | cypresstwist | Conversion | 8 | 02-22-2011 09:28 AM |
ebook-convert won't work in a batch file since 0.6.17 | mbovenka | Calibre | 20 | 01-13-2011 07:03 PM |
Batch processing of PDB files? | Asterra | iRex | 6 | 12-04-2007 01:10 PM |
Batch-convert Rocket Ebook format for GEB2150? | Fauve | Fictionwise eBookwise | 1 | 04-28-2007 05:12 PM |