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

Go Back   MobileRead Forums > E-Book Software > Calibre


Thread Tools Search this Thread
Old 12-10-2012, 08:09 PM   #1
dancal began at the beginning.
Posts: 16
Karma: 10
Join Date: Dec 2012
Device: PC
Script: store calibre ebooks as symlinks to existing lib; advanced CLI import

Calibre is great for browsing a library, but it takes the position that "all your file(names) are belong to us". Some of us have had an e-book library for years, and want to retain ownership of filenames and directories. My script enables you to store existing e-books in Calibre WITHOUT DUPLICATING STORAGE.

Run " -h" for help, and read below.

On Linux and Mac, e-books are stored as symlinks to existing files; on Windows, as hardlinks (for XP compatibility).

This script allows you to import a list of e-books and generate metadata automatically from filenames, using either simple regexps, or arbitrary Python expressions.

Example: my filenames are formatted as "AUTHOR1, AUTHOR2-TITLE [ATTR1=VAL1, ATTR2=VAL2].pdf" (attributes, such as ISBN, publication date etc. appear in random order):

Floyd Marinescu-EJB design patterns [license=free, isbn=0471208310, googleid=hpFdoX2ICckC, date=2002-02-19].pdf

To import these files into Calibre with metadata, I used --links --match '([^-]+)-([^[.]+)( \[)|\.' --tag title=2 --tag authors='lambda (g): g [1].replace (", ", " & ")' --match '.*isbn=([-0-9X]+)' --tag isbn=1 --dir ~/Downloads/CalibreLibIds *.pdf

Each --match is executed and stored, then subsequent --tag arguments can assign authors, date etc. based on that match.

In this example, for titles it was enough to pull the 2nd match group of the --match regex (--tag title=2). For AUTHORS -- since they were separated by commas instead of ampersands, I used a custom str.replace expression to fix that (--tag author='lambda g:...').

The script stores the original filenames in a separate directory (above, ~/Downloads/CalibreLibIds). Calibre tends to copy files around even for simple operations such as downloading metadata, destroying the links. Thus you might want to run " --dir MYDIR --links --rebuild" to reclaim storage.

The --dir should be stored safely, preferably outside Calibre's dirs.
Attached Files
File Type: zip (3.4 KB, 76 views)
dancal is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import existing .opf's & books haiyeekayakee Calibre 7 06-26-2017 09:17 PM
CLI Metdata Change on Import axlrod Library Management 1 10-11-2011 03:11 PM
Import ebooks to Calibre from Kindle krikket Devices 2 03-02-2011 05:41 PM
Adding existing collection of ebooks to calibre Chris_147 Calibre 2 09-30-2010 09:35 AM

All times are GMT -4. The time now is 05:28 PM. is a privately owned, operated and funded community.