GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Calibre Buttons

Updated: 16/2/2020

  • New Author Search function.
  • Convert to AZW3 added.
  • Convert to PDF added.
  • Minor tweaks to other buttons to suit Opus changes since these were created.

A few buttons to manipulate eBooks and your Calibre Database:

For convenience here's a complete toolbar ready for you to use: Calibre.zip (942 Bytes)

Alternatively, if you wish to use the individual buttons below, here is how to use the code blocks: How to use buttons and scripts from this forum

Create Book List

This one creates a file called "booklist.txt" in the current source directory of Opus. This list contains author, title, series and series_index for each book. There are additional arguments which can be added to include other columns (see https://manual.calibre-ebook.com/generated/en/calibredb.html for further info).

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Create Book List</label>
	<icon1>C:\Program Files (x86)\Calibre2\calibre.exe,0</icon1>
	<function type="batch">
		<instruction>@runmode:hide</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\calibredb.exe&quot; list --ascending --fields authors,title,series,series_index --sort-by authors --line-width 500 &gt; &quot;{sourcepath$}BookList.txt&quot;</instruction>
	</function>
</button>

Author Search...

Prompts for an author name (or partname) and creates a text file in the source folder (named identically to your search.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>Author Search...</label>
	<icon1>C:\Program Files (x86)\Calibre2\calibre.exe,0</icon1>
	<function type="batch">
		<instruction>@runmode:hide</instruction>
		<instruction>@set strAuthor={dlgstring|Enter author name}</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\calibredb.exe&quot; list --search &quot;{$strAuthor}&quot; --ascending --fields authors,title,series,series_index --sort-by authors --line-width 1000  &gt; &quot;{sourcepath$}{$strAuthor}.txt&quot;</instruction>
	</function>
</button>

Add Book/s

Add all selected files to the Calibre database.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Add Book/s</label>
	<icon1>#newcommand</icon1>
	<function type="batch">
		<instruction>&quot;C:\Program Files (x86)\Calibre2\calibredb.exe&quot; add &quot;{filepath}&quot;</instruction>
		<instruction>pause</instruction>
	</function>
</button>

View Book

View the first selected file in Opus in the Calibre book viewer. Selected file must be a valid ebook format of course.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>View eBook</label>
	<icon1>#viewerpane2</icon1>
	<function type="normal">
		<instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-viewer.exe&quot; {filepath}</instruction>
	</function>
</button>

Convert to AZW3

Converts all selected files to the Kindle compatible .azw3 format. This will work with a pile of ebook formats including .pdf. The converted file will have the same name as the source file with the .azw3 extension of course. These will be created in the same folder as the source file.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Convert to AZW3</label>
	<icon1>#imageconversion</icon1>
	<function type="normal">
		<instruction>cd {sourcepath$}</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .azw3</instruction>
	</function>
</button>

Convert to MOBI

The same as the AZW3 converter but it will convert to MOBI format.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Convert to MOBI</label>
	<icon1>#imageconversion</icon1>
	<function type="normal">
		<instruction>cd {sourcepath$}</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .mobi</instruction>
	</function>
</button>

Convert to EPUB

The same as the AZW3 converter but it will convert to EPUB (Not Kindle compatible) format.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
 <label>Convert to EPUB</label>
 <icon1>#imageconversion</icon1>
 <function type="normal">
  <instruction>cd &quot;{sourcepath$}&quot;</instruction>
  <instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .epub</instruction>
 </function>
</button>

Convert to PDF

The same as the AZW3 converter but it will convert to PDF format. Be aware that there can be issues with PDF conversion, it doesn't always work well. The Calibre forums are full of people with PDF conversion issues.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>Convert to PDF</label>
	<icon1>#imageconversion</icon1>
	<function type="normal">
		<instruction>cd &quot;{sourcepath$}&quot;</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .pdf</instruction>
	</function>
</button>
1 Like

Thanks! These are really useful for me.

Made my day, just what I needed.

Thank you

Just installed the converstion buttons yesterday. Wow! Thank you, thank you, thank you!

Good stuff. Thought Calibre was a pain in the *** until now.

So here (obviously) is a conversion to PDF, but it would be neat to have a dialogue pop up asking you your desired font size.
I tried to figure it out how to change the command from here
http://manual.calibre-ebook.com/cli/ebook-convert.html
but didn't get much joy.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
 <label>Convert to EPUB</label>
 <icon1>#imageconversion</icon1>
 <function type="normal">
  <instruction>cd &quot;{sourcepath$}&quot;</instruction>
  <instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .pdf</instruction>
 </function>
</button>

Did you read this sticky on Calibre Forums re PDF conversions: http://www.mobileread.com/forums/showthread.php?t=118605 ?

That sticky suggests using the Mobipocket Creator program.

It's free and IMO it works better than most other PDF converters, including Calibre and some payware programs. It Creates PRC files which Calibre can handle 'peacefully'.

The Calibre Manual also includes this statement: http://calibre-ebook.com/user_manual/conversion.html#convert-pdf-documents

BR

Thanks.

But my wish list concerned converting to PDF.

The default font is always too small.
I have good luck when I boosted the font size in Calibre, but again, it's a pain.
Just wish I could do it via a DOpus dialog box.

[quote="dwilbank"]Thanks.

But my wish list concerned converting to PDF.

The default font is always too small.
I have good luck when I boosted the font size in Calibre, but again, it's a pain.
Just wish I could do it via a DOpus dialog box.[/quote]
Sorry, most PDF related complaints about calibre are related to converting from PDF. And the link you gave was about converting from PDF

What is the input file type you're wanting to convert to PDF.

BR

Epub mainly.

Use Calibre Conversion Command Line manual.calibre-ebook.com/cli/ebook-convert.html

Everything you can adjust in Calibre's Conversion dialogue boxes, is accessible from the command line.

When you have what you want then attach the command to an Opus button.

BR

Thanks for sharing. Very useful!

Hello,
I just want to share with you my button to modify the title and the author of an ebook, using ebook-meta.exe from Calibre, and using the file name and its path as title and author :

For example, imagine that your files are organized like this :

C:\my\complete\path\ROBILLARD Anne\[Les Chevaliers d'Emeraude-01]Le Feu dans le ciel.epub

(or .mobi)

Use this command to assign ROBILLARD Anne as the author of the book, and [Les Chevaliers d'Emeraude-01]Le Feu dans le ciel as the name of the book :

"C:\Program Files (x86)\Calibre2\ebook-meta.exe" {filepath} -t "{file|noext}" -a "{sourcepath|nopath|noterm}"

Now imagine that your book is stored in a path, including the name of the collection :

C:\my\complete\path\ROBILLARD Anne\Les chevaliers d'Emeraude\[Les Chevaliers d'Emeraude-01]Le Feu dans le ciel.epub

(or .mobi)

Use this command instead, to use the parent folder as the name of the author:

"C:\Program Files (x86)\Calibre2\ebook-meta.exe" {filepath} -t "{file|noext}" -a "{sourcepath|..|nopath|noterm}"

If the name of the author is higher in the path, replace the .. by ..\.. for one level up, ..\..\.. for one more etc...

I hope that helps... :slight_smile:

I'm going to play with that a bit, but it looks like it should be very useful. Thanks!

Small update to the root post with a couple of new buttons.

2 Likes

Not sure if you're still wanting this (it was years ago after all :slight_smile: ) but here's a button to convert any format to PDF and it prompts you for a font size.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>Convert to PDF</label>
	<tip>Convert to PDF with font size selection.</tip>
	<icon1>#imageconversion</icon1>
	<function type="normal">
		<instruction>cd &quot;{sourcepath$}&quot;</instruction>
		<instruction>&quot;C:\Program Files (x86)\Calibre2\ebook-convert.exe&quot; {filepath} .pdf --pdf-default-font-size {dlgstringS|Enter Font Size|24}</instruction>
	</function>
</button>

Thank you sir. I'll try it right now!