12-20-2021, 02:03 PM | #1 |
Member
Posts: 11
Karma: 10
Join Date: Dec 2020
Device: Kobo Libra H2O
|
Send to Device based on file format
Hello.
I've been trying to send books to different destinations on my device, based on the file type. Imagine I have two formats in my Calibre library, kepub and epub. I want to send kepubs to books/author/title, and epubs to .books/author-series-series_index-title. I've wrote the following "model" but it doesn't work: Code:
program: if field('formats') == "kepub" then return strcat("books", "/", field('authors'), field('title')) else return strcat(".books/", field('authors'), "-", field('series'), "-", field('series_index'), "-", field('title'), field('formats')) fi; Any help would be appreciated. |
12-21-2021, 01:28 AM | #2 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
In what way doesn't it work? Is it not working at all? Or is only part of it not working? And there is no were near enough explanation of what you are actually trying to achieve. For example, are you trying to send a kepub when it exists, or only if it is the only format. Or the only format that is supported by the device.
But, I can think of two problems. The test 'field('formats') == 'kepub'' will only return true if the only format you have for the book is kepub. If you have anything else as well, it will be false. But, the driver is probably set to send the kepub in preference to the epub or other format. And you will have problems if you have a kepub and a non-supported format such as AZW3. The kepub will be sent, but, the test will fail. You probably want to use "'KEPUB' in field('formats')". That will return true if one of the formats for the books is kepub. The other problem is that calibre sanitises the file path when sending the book. That means for the non-kepub path, the leading dot is probably going to be changed to an underscore. |
12-21-2021, 02:47 AM | #3 |
Member
Posts: 11
Karma: 10
Join Date: Dec 2020
Device: Kobo Libra H2O
|
I'm sorry for not being specific enough.
My library contains two types of books: 1- epubs that have kepub versions created with kepubify 2- PDF documents PDFs aside, I'd like that when I send a specific format, let's say epubs, they go to a hidden folder for use with KOReader, and when I send another format, kepub, they go to a regular books directory for use with nickel. This is so I can have different “libraries” for me and my wife on the same device. Using 'KEPUB' or 'kepub' makes no difference. If I use an elif instead of else the resulting file names are just the id number and the file extension, put in the device root. If not it's always the else clause that is used. The test is always false. If the dot always gets turned into an underscore then I don't think I can hide epubs from nickel. |
12-21-2021, 08:19 AM | #4 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
In that case, all you need to do is to change the condition for the kepub to what I said. That will put the kepub version where you want it when it. Which means it looks like:
Code:
program: if 'KEPUB' in field('formats') then return strcat("books", "/", field('authors'), field('title')) else return strcat(".books/", field('authors'), "-", field('series'), "-", field('series_index'), "-", field('title'), field('formats')) fi; |
12-21-2021, 09:00 AM | #5 |
Member
Posts: 11
Karma: 10
Join Date: Dec 2020
Device: Kobo Libra H2O
|
That condition is always false.
Both files are saved to the same location with the same name (except for the extension). Guess I won't be able to do it. If only the kobotouchextended or something would convert to one location and copy the epub to another on the device. It would achieve what I need. |
12-21-2021, 09:45 PM | #6 | |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
The test you are using is basically, "Do I have a kepub as one of the formats for the current book?" And the answer is apparently no. Change the test to use "epub" and it should do what you want. I don't remember exactly when calibre runs the template, so I am not sure if it is possible to work out exactly what format is being sent. |
|
Tags |
filetypes, formats, send to device |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Send to device based on Tag | wishingstar | Devices | 6 | 03-15-2017 10:05 AM |
Different Send to Device routine based on the library. | iatheia | Library Management | 10 | 01-24-2012 12:06 PM |
Send to device based on Metadata | DavidTC | Calibre | 0 | 09-18-2011 01:18 PM |
send to device format preference | cybmole | Calibre | 15 | 09-30-2010 03:46 AM |
How to control which format to send to device | ddavtian | Calibre | 1 | 10-16-2008 03:28 AM |