View Single Post
Old 01-04-2012, 03:41 PM   #25
Krogenar
It's Facebook!
Krogenar began at the beginning.
 
Krogenar's Avatar
 
Posts: 10
Karma: 10
Join Date: Jun 2011
Device: Nook Color
Chaley, thanks for your help!

Quote:
Originally Posted by chaley View Post
You cannot create more than one path for a given book within one save operation. The only way to create the duplicates is to do multiple save operations using different templates.
Ok.

Quote:
Originally Posted by chaley
If you can guarantee that a book never appears in more than one top-level genre, then the following template will do it.
Code:
{#genre:subitems(0,1)||/}{author}/{title}
However, if it is possible that a book can have more than one top-level genre, such as Japanese.History and Military.History, then the above template will produce "Japanese, Military". This may or may not be what you want.
The genre field always contains at least the term 'FICTION' or 'NON-FICTION' but never both.

Quote:
Originally Posted by chaley
It may turn out that the simplest thing to do is to add another column (text, not tags-like) in which you manually enter the folder name to be used on the device.
Here's what I've tried to do. I've created a derived column called 'directories' and decided that if the books go just one sublevel down (i.e.: FICTION.HORROR would send to /BOOKS/FICTION/HORROR/) that would be acceptable. So I figured if I could get the 'directories' field to list just one level below either FICTION or NON-FICTION it would still be a great benefit.

My template for 'directories' column is:

Code:
{#genre:sublist(0,1,\,)}
I noticed that the 'genres' column is always alphabetically sorted, starting with one of the top two hierarchy terms (FICTION or NON-FICTION), and then lists the second tier terms alphabetically, and then deeper hierarchies.

Example:
Code:
FICTION, FICTION.HORROR, FICTION.THRILLER, FICTION.THRILLER.MEDICAL
So my plan was to grab the second item in the list, so that the 'directories' column would read"
Code:
FICTION.HORROR
Then all I would have to do is figure out a way to convert the period (.) into a slash (/) and I could use that field in my 'Send to Device' templates. Not perfect, but good enough!

But there's a complication (aside from my not knowing how to replace the periods yet.) -- when Calibre displays the contents of the 'genres' field in the tableview, it sorts them alphabetically... but the field contents may not be in the same order. When this programming grabs the second term in the string, it grabs not from the column, but from the actual field contents.

Now, I see that there are functions to sort strings, so I could sort the 'genre' string and then grab the second term, but how can I nest commands? Can I?

Again, thanks for the help.
Krogenar is offline   Reply With Quote