Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 06-28-2013, 12:00 AM   #1
Blunaigel
Junior Member
Blunaigel began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Batch processing with kindlegen

Hi all,

how can I convert multiple epub files in a batch using kindlegen?


... well yeah the question is as simple as this.
Blunaigel is offline   Reply With Quote
Old 06-28-2013, 02:42 AM   #2
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,689
Karma: 4392001
Join Date: Dec 2010
Device: Kindle 3
Quote:
Originally Posted by Blunaigel View Post
how can I convert multiple epub files in a batch using kindlegen?
Create a text file with the following one liner in it and save it with the extension .CMD or .BAT:

Code:
FOR %%f IN ("*.epub") DO ( kindlegen "%%f" >> conversion.log )
Then copy the batch file and Kindlegen.exe to the folder with your epubs in it and double-click the batch file. If files fail to convert check the error messages in conversion.log.

Note that KindleGen will attach the source files to the .mobi files. If space is an issue, you'll need to use KindleStrip to strip off the source files.
Doitsu is offline   Reply With Quote
Old 06-29-2013, 01:15 AM   #3
Blunaigel
Junior Member
Blunaigel began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Thank you very much!

Can I include a command to tell kindlegen to use the "-c2" format?

(Sorry, I'm not really used to .bat-files. :/ )


EDIT: oh and how about batch-processing with kindlestrip?
Blunaigel is offline   Reply With Quote
Old 06-30-2013, 04:17 AM   #4
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 61,021
Karma: 38262005
Join Date: Nov 2006
Location: UK
Device: Kindle PW2, iPad Retina Mini, iPhone 4, MS Surface Pro
You can include any flags you want on the command line.
HarryT is offline   Reply With Quote
Old 06-30-2013, 01:05 PM   #5
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,689
Karma: 4392001
Join Date: Dec 2010
Device: Kindle 3
Quote:
Originally Posted by Blunaigel View Post

Can I include a command to tell kindlegen to use the "-c2" format?
As HarryT has already correctly pointed out, you can simply add the -c2 switch after Kindlegen, however, since Kindlegen will run several optimization passes for each file, I wouldn't recommend using the -c2 switch in batch files.

Quote:
Originally Posted by Blunaigel View Post
EDIT: oh and how about batch-processing with kindlestrip?
Assuming that you have ActivePython (or another Python 2.7 build) installed and Kindlestrip.py is the same folder as the batch file, you could use the following very simple batch file:

Code:
DEL conversion.log
FOR %%f IN ("*.epub") DO  (
	kindlegen "%%f" >> conversion.log
	IF EXIST "%%~nf.mobi" (
		ECHO ******************************* >> conversion.log
		kindlestrip "%%~nf.mobi" "%%~nf.new" >> conversion.log
		IF EXIST "%%~nf.new" (	
			DEL "%%~nf.mobi"
			REN "%%~nf.new" "%%~nf.mobi"
		)
	) 
)
The batch file works with KindleGen 2.9 and Kindlestrip 1.35.
Doitsu is offline   Reply With Quote
Old 06-30-2013, 03:52 PM   #6
RbnJrg
Addict
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 376
Karma: 255494
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Doitsu View Post
As HarryT has already correctly pointed out, you can simply add the -c2 switch after Kindlegen, however, since Kindlegen will run several optimization passes for each file, I wouldn't recommend using the -c2 switch in batch files.



Assuming that you have ActivePython (or another Python 2.7 build) installed and Kindlestrip.py is the same folder as the batch file, you could use the following very simple batch file:

Code:
DEL conversion.log
FOR %%f IN ("*.epub") DO  (
	kindlegen "%%f" >> conversion.log
	IF EXIST "%%~nf.mobi" (
		ECHO ******************************* >> conversion.log
		kindlestrip "%%~nf.mobi" "%%~nf.new" >> conversion.log
		IF EXIST "%%~nf.new" (	
			DEL "%%~nf.mobi"
			REN "%%~nf.new" "%%~nf.mobi"
		)
	) 
)
The batch file works with KindleGen 2.9 and Kindlestrip 1.35.
Very nice script! And if you have a folder only with .mobi books and want to apply kindlestrip, how would it be the .bat file? Many thanks in advance.
RbnJrg is offline   Reply With Quote
Old 06-30-2013, 04:29 PM   #7
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 1,689
Karma: 4392001
Join Date: Dec 2010
Device: Kindle 3
Quote:
Originally Posted by RbnJrg View Post
Very nice script! And if you have a folder only with .mobi books and want to apply kindlestrip, how would it be the .bat file? Many thanks in advance.
That's very easy. You simply omit the KindleGen part, change the file selector to .mobi and end up with this very simple script.

Code:
DEL conversion.log
FOR %%f IN ("*.mobi") DO  (
		ECHO ******************************* >> conversion.log
		kindlestrip "%%~nf.mobi" "%%~nf.new" >> conversion.log
		IF EXIST "%%~nf.new" (	
			DEL "%%~nf.mobi"
			REN "%%~nf.new" "%%~nf.mobi"
		) ELSE ( 
		ECHO  "%%~nf.mobi" was NOT stripped! >> conversion.log
		)
)
Hopefully, none of the "real programmers" will see this, because it's a quick & dirty solution that doesn't follow the traditional programming guidelines.

BTW, as with the other batch file there's always the possibility that something might go horribly wrong.
Always keep backups and don't use it with the original files.
Doitsu is offline   Reply With Quote
Old 06-30-2013, 05:45 PM   #8
RbnJrg
Addict
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 376
Karma: 255494
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Doitsu View Post
That's very easy. You simply omit the KindleGen part, change the file selector to .mobi and end up with this very simple script.

Code:
DEL conversion.log
FOR %%f IN ("*.mobi") DO  (
		ECHO ******************************* >> conversion.log
		kindlestrip "%%~nf.mobi" "%%~nf.new" >> conversion.log
		IF EXIST "%%~nf.new" (	
			DEL "%%~nf.mobi"
			REN "%%~nf.new" "%%~nf.mobi"
		) ELSE ( 
		ECHO  "%%~nf.mobi" was NOT stripped! >> conversion.log
		)
)
Hopefully, none of the "real programmers" will see this, because it's a quick & dirty solution that doesn't follow the traditional programming guidelines.

BTW, as with the other batch file there's always the possibility that something might go horribly wrong.
Always keep backups and don't use it with the original files.
Thank you very much Doitsu!!
RbnJrg is offline   Reply With Quote
Old 03-28-2014, 04:31 PM   #9
radius
Lector minore
radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.radius trips the light fantastic.
 
radius's Avatar
 
Posts: 327
Karma: 128734
Join Date: Jan 2008
Device: Sony PRS-505, BlackBerry Playbook
Quote:
Originally Posted by Doitsu View Post
As HarryT has already correctly pointed out, you can simply add the -c2 switch after Kindlegen, however, since Kindlegen will run several optimization passes for each file, I wouldn't recommend using the -c2 switch in batch files.
Why not? If this is a batch, then presumably you aren't running it in anything like an interactive mode. So if it takes longer, that just means you have time for two cups of coffee instead of one.

Is there any reason other than time/CPU+disk usage not to use the higher compression?
radius is offline   Reply With Quote
Old 04-21-2014, 07:37 PM   #10
Thalia Helikon
Enthusiast
Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.Thalia Helikon figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Thalia Helikon's Avatar
 
Posts: 29
Karma: 110336
Join Date: Dec 2011
Location: Los Angeles, CA
Device: Kindle n-T, Archos 7 Tablet, BlkB Curve & Torch, Nook Color Tablet
how would the code be different in a Linux terminal?
Thalia Helikon is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting ebook-convert for batch parallel processing? joewiz Conversion 9 03-15-2013 05:34 AM
Tag editor with batch processing semenoof General Discussions 0 01-17-2013 03:12 AM
Batch processing of PDB files? Asterra iRex 6 12-04-2007 01:10 PM


All times are GMT -4. The time now is 04:49 AM.


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