
ebook - create and manipulate e-books from the command line

ebook COMMAND arg1 arg2 --opt1 --opt2
See also "EXAMPLES".

adddocAdds a documents to both the book manifest and spine.
--opffile--opfThe OPF file to modify. If not specified one will be searched for in the current directory.
--identifier--idThe ID attribute to use for the added manifest item. This is required, and ebook will abort if it is not specified.
--mimetype--mtypeThe mime type string to use for the added manifest item. If not specified, it will be autodetected via File::Mimeinfo::Magic. This may not result in an optimal string.
ebook adddoc --opf mybook.opf --id 'text-ch1' chapter1.html
additemAdd an item to the book manifest, but not the spine.
Note that the "fix" command will automatically insert manifest items for any local files referenced by existing manifest items.
--opffile--opfThe OPF file to modify. If not specified one will be searched for in the current directory.
--identifier--idThe ID attribute to use for the added manifest item. This is required, and ebook will abort if it is not specified.
--mimetype--mtypeThe mime type string to use for the added manifest item. If not specified, it will be autodetected via File::Mimeinfo::Magic. This may not result in an optimal string.
ebook additem --opf mybook.opf --id 'illus-ch1' chapter1-illus.jpg
blankCreate a blank e-book structure.
--opffile filename.opf--opf filename.opfUse the specified OPF file. This can also be specified as the first non-option argument, which will override this option if it exists. If no file is specified, the program will abort with an error. =item --author "Author Name"
The author of the book. If not specified, defaults to "Unknown Author".
--title "Title Name"The title of the book. If not specified, defaults to "Unknown Title".
--dir directory-d directoryOutput the OPF file in this directory, creating it if necessary.
ebook blank newfile.opf --author "Me Myself" --title "New File" ebook blank --opffile newfile.opf --author "Me Myself" --title "New File"
Both of those commands have the same effect.
configMake changes to the EBook::Tools configuration file.
The configuration file itself is located as either $ENV{HOME}/.ebooktools/config.ini or as $ENV{USERPROFILE}\Application Data\EBook-Tools, depending on platform and which directory is found first. See "userconfigdir()" in EBook::Tools for details.
Configuration is always handled in the format of:
ebook config subcommand value
default
Replace any existing configuration file with a default template. This creates the file if it does not exist. This should be done once before any other configuration manipulation is done, unless a configuration file has been manually created ahead of time.
debug
Sets the default debugging level when no verbosity is specified. Note that verbosity can only be increased, not decreased, with the -v option.
tidysafety
Sets the default safety level when tidy is used. Valid values are from 0-4. See "unpack" for details on what each value means.
mobipids
A comma-separated list of Mobipocket PIDs to try to use to decrypt e-books. This value is only used if the appropriate plug-in modules or helper applications are available, as DRM is not supported natively by EBook::Tools. Note that if the PID includes a $ character, the entire PID string has to be enclosed in single quotes.
ebook config default ebook config debug 2 ebook config mobipids '1234567890,2345678$90'
downconvertdcIf the appropriate helpers or plugins are available, write a copy of the input file with the DRM restrictions removed.
NOTE: no actual DRM-removal code is present in this package. This is just presents a unified interface to other programs that have that capability.
infile
The first non-option argument is taken to be the input file. If not specified, the program exits with an error.
outfile
The second non-option argument is taken to be the output file. If not specified, the program will use a name based on the input file, appending '-nodrm' to the basename and keeping the extension. In the special case of Mobipocket files ending in '-sm', the '-sm' portion of the basename is simply removed, and nothing else is appended.
key
The third non-option argument is taken to be either the decryption key/PID, or in the case of Microsoft Reader (.lit) files, the keys.txt file containing the decryption keys.
If not specified, this will be looked up from the configuration file. Convertlit keyfiles will be looked for in standard locations. If no key is found, the command aborts and exits with an error.
ebook downconvert NewBook.lit NewBook-readable.lit mykeys.txt ebook dc MyBook-sm.prc
fixFind and fix problems with an e-book, including enforcing a standard specification and ensuring that all linked objects are present in the manifest.
--opffile filename.opf--opf filename.opfUse the specified OPF file. This can also be specified as the first non-option argument, which will override this option if it exists. If no file is specified, one will be searched for.
--oeb12Force the OPF to conform to the OEB 1.2 standard. This is the default.
--opf20Force the OPF to conform to the OPF 2.0 standard. If both this and --oeb12 are specified, the program will abort with an error.
--mobiCorrect Mobipocket-specific elements, creating an output element to force UTF-8 output if one does not yet exist.
--dir directory-d directorySave the fixed output into the specified directory. The default is to write all output in the current working directory. Note that this only affects the output, and not where the OPF file is found.
genepubGenerate a .epub book from existing OPF data.
--input filename.opf--i filename.opf--opffile filename.opf--opf filename.opfUse the specified OPF file. This can also be specified as the first non-option argument, which will override this option if it exists. If no file is specified, one will be searched for.
--output bookname.epub-o bookname.epubUse the specified name for the final output file. If not specified, the bok will have the same filename as the OPF file, with the extension changed to .epub.
--dir directory-d directoryOutput the final .epub book into the specified directory. The default is to use the current working directory.
ebook genepub mybook.opf -f my_special_book.epub -d ../epubbooks
or in the simplest case:
ebook genepub
genimpGenerate a eBookwise .imp book from a .RES directory
--input DIRNAME.RES-i DIRNAME.RESSpecifies the resource directory to use for input. A valid resource directory will contain at least a RSRC.INF file, a DATA.FRK file, and several other files with four-capital-letter filenames.
This can also be specified as the first non-option argument, which will override this option if it exists. If not specified, the current directory will be used.
--output bookname.epub-o bookname.epubUse the specified name for the final output file. If not specified, the book will have the same filename as the input, with the extension changed to .imp.
ebook genimp MyUnpackedBook.RES MyBook.imp ebook genimp --resdir ../MyUnpackedBook.RES -f imp/MyBook.imp
genmobiGenerate a Mobipocket .mobi/.prc book from OPF, HTML, or ePub input.
--input filename--i filenameUse the specified file for input. Valid formats are OPF, HTML, and ePub. This can also be specified as the first non-option argument, which will override this option if it exists. If no file is specified, an OPF file in the current directory will be searched for.
--output bookname.prc-o bookname.prcUse the specified name for the final output file. If not specified, the book will have the same filename as the input file, with the extension changed to .mobi (this file is always created by mobigen, specifying a different filename only causes it to be renamed afterwards).
This can also be specified as the second non-option argument, which will override this option if it exists.
--dir directory-d directoryOutput the final book into the specified directory. The default is to use the current working directory, which is where mobigen will always place it initially; if specified this only forces the file to be moved after generation.
--compression x-c xUse the specified compression level x, where 0 is no compression, 1 is PalmDoc compression, and 2 is HUFF/CDIC compression. If not specified, defaults to 1 (PalmDoc compression).
ebook genmobi mybook.opf -o my_special_book.prc -d ../mobibooks ebook genmobi mybook.html mybook.prc -c2
or in the simplest case:
ebook genmobi
impmetaSet specific metadata values in an ETI .imp file.
--input filename.imp-i filename.imp
Specify the input filename. This can also be specified as the first argument, in which case the -i option will be ignored.
--output modified.imp-o modified.imp
Specify the output filename. If not specified, the input file will be overwritten.
--identifier
Specify the identifier metadata.
--category--cat
Specify the category metadata.
--subcategory--subcat
Specify the subcategory metadata.
--title
Specify the title metadata.
--lastname
Specify the author last name metadata.
--middlename
Specify the author middle name metadata.
--firstname
Specify the author first name metadata. Note that IMP files commonly place the full name in this component, and leave the middlename and lastname entries blank.
ebook impmeta mybook.imp --title 'Fixed Title' --lastname 'John Q. Brandy' ebook impmeta -i mybook.imp -o fixed.imp --title 'Fixed Title'
setmetaSet specific metadata values on an OPF file, creating a new entry only if none exists.
Both the element to set and the value are specified as additional arguments, not as options.
The elements that can be set are currently 'author', 'title', 'publisher', and 'rights'.
--opffile =item * --opf
Specifies the OPF file to modify. If not specified, the script will attempt to find one in the current directory.
--fileas
Specifies the 'file-as' attribute when setting an author. Has no effect on other elements.
--identifier--id
Specifies the ID to assign to the element.
ebook setmeta title 'My Great Title' ebook --opf newfile.opf setmeta author 'John Smith' --fileas 'Smith, John' --id mainauthor
splitmetaSplit the <metadata>...</metadata> block out of a pseudo-HTML file that contains one.
splitpreSplit <pre>...</pre> blocks out of an existing HTML file, wrapping each one found into a separate HTML file.
The first non-option argument is taken to be the input file. The second non-option argument is taken to be the basename of the output files.
stripscriptStrips <script>...</script> blocks out of a HTML file.
The first non-option argument is taken to be the input file. The second non-option argument is taken to be the output file. If the latter is not specified, the input file will be overwritten.
--noscript
Strips <noscript>...</noscript> blocks as well.
tidyxhtmlRun tidy on a HTML file to enforce valid XHTML output (required by the OPF 2.0 specification).
tidyxmlRun tidy an a XML file (for neatness).
unpackUnpacks an ebook into its component parts, creating an OPF for them if necessary.
--input =item -iThe filename of the ebook to unpack. This can also be specified as the first non-option argument, in which case it will override the option if it exists.
--dir =item -dThe directory to unpack into, which will be created if it does not exist, defaulting to the filename with the extension removed. This can also be specified as the second non-option argument, in which case it will override the option if it exists.
--formatThe unpacking routines should autodetect the type of book under normal conditions. If autodetection fails, a format can be forced here. See EBook::Tools::Unpack for a list of available formats.
--htmlconvertAttempt to convert the extracted text to HTML. This is obviously only of value if the format doesn't use HTML normally.
--rawThis causes a lot of raw, unparsed, unmodified data to be dumped into the directory along with everything else. It's useful for debugging exactly what was in the file being unpacked, but not for much else.
--authorSet the primary author of the unpacked e-book, overriding what is detected. Not all e-book formats contain author metadata, and if none is found and this is not specified the primary author will be set to 'Unknown Author'.
--titleSet the title of the unpacked e-book, overriding what is detected. A title will always be detected in some form from the e-book, but the exact text can be overridden here.
--opffile--opfThe filename of the OPF metadata file that will be generated. If not specified, defaults to the title with a .opf extension.
--tidyRun tidy on any HTML output files to convert them to valid XHTML. Be warned that this can occasionally change the formatting, as Tidy isn't very forgiving on certain common tricks (such as empty <pre> elements with style elements) that abuse the standard.
--tidycmdThe tidy executable name. This has to be a fully qualified pathname if tidy isn't on the path. Defaults to 'tidy'.
--tidysafetyThe safety level to use when running tidy (default is 1). Potential values are:
$tidysafety < 1:No checks performed, no error files kept, works like a clean tidy -m
This setting is DANGEROUS!
$tidysafety == 1:Overwrites original file if there were no errors, but even if there were warnings. Keeps a log of errors, but not warnings.
$tidysafety == 2:Overwrites original file if there were no errors, but even if there were warnings. Keeps a log of both errors and warnings.
$tidysafety == 3:Overwrites original file only if there were no errors or warnings. Keeps a log of both errors and warnings.
$tidysafety = 4>:Never overwrites original file. Keeps a log of both errors and warnings.
ebook unpack mybook.pdb My_Book --author "By Me" ebook unpack -i mybook.pdb -d My_Book --author "By Me"
Both of the above commands do the same thing

ebook splitmeta book.html mybook.opf ebook tidyxhtml book.html ebook tidyxml mybook.opf ebook fix mybook.opf --oeb12 --mobi ebook genepub ebook blank newbook.opf --title "My Title" --author "My Name" ebook adddoc myfile.html ebook fix newbook.opf --opf20 -v ebook genepub ebook unpack mybook.pdb my_book cd my_book ebook addoc new_document.html ebook fix ebook genepub


Copyright 2008 Zed Pobre

Licensed to the public under the terms of the GNU GPL, version 2.