10-21-2010, 02:16 AM | #1 |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Send to device in special folder structure
I have many books, including some very large series (eg. the Perry Rhodan series already has about 450 books and is increasing every week)
Each page can show 10 books, so, I made a structure which looks just like this: Comics Drama Romantic Fiction Fiction\Harry Potter Fiction\... SciFi\ SciFi\Perry Rhodan SciFi\Perry Rhodan\0001-0100 SciFi\Perry Rhodan\0001-0100\0001-0010 SciFi\Perry Rhodan\0001-0100\0011-0020 SciFi\Perry Rhodan\0001-0100\0021-0030 etc... SciFi\Perry Rhodan\0101-0200 etc... I know I could misuse the author field, but then I have pages consisting of at least 50 entries, which makes browsing through the library extremely slow. Is it possible to have a property for each book in Calibre which containts the location on the ebook? This property could be filled automatically with author, but can be overridden by the user. (I hope you understand this problem and the possible solution) |
10-21-2010, 04:16 AM | #2 |
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I assume that the numbers being shown above are the series index? If so, you are looking for a way to change a series index into some hierarchy?
There is no automatic way to do the arithmetic necessary to convert a series index of (say) 147 into the string 0101-0200/0140-0149. That said, you can do it manually on a book by book basis. Create two text custom columns, one for the first level of the index (lets call this #index1) and one for the second (lets call this #index2). Put the index-level folder names you want into them. For example, for book 147, you would put 0101-0200 into #index1, and 0140-0149 into #index2. You don't say where the genre comes from. I will assume you have a custom column called #genre. (You could use tags, of course.) Given the above, you would use a save template that would look something like {#genre}/{series:||/}{#index1:||/}{#index2:||/}{title} See http://calibre-ebook.com/user_manual/template_lang.html for a description of the template language. |
10-21-2010, 04:20 AM | #3 |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Thanks, I will try this!
I made a column with FolderOnEbook. I will fill this for book 147 with: 0101-0200/0141-0150 Another column with Genre will be filled with: SciFi The template will be: {#genre:||/}{#folderOnEbook:||/}{title} The title of the book is: 'Perry Rhodan 0147 - Time warp' So, I will get: SciFi/0101-0200/0141-0150/Perry Rhodan 0147 - Time warp I hope this will do it! Is it also possible to have another folder structure in the Catalog folder on my disk? (I tried to use the template '{#genre:||/}{series}/{title}', but this did not change anything when I put something in the Genre field) edit: Don't think the catalog structure is interesting... I can 'export' to disk instead. Last edited by Arco Witter; 10-21-2010 at 05:46 AM. |
10-21-2010, 06:54 AM | #4 |
Grand Sorcerer
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
|
Why not do the same as I have with my folder structure?
{author_sort:switch(^[A-D],[A - D],^[E-J],[E - J],^[K-O],[K - O],^[P-T],[P - T],^[U-Z],[U - Z],[Other])} So, something like: {series_index:switch(00[0-9][0-9], 0000-0099, 01[0-9][0-9], 0100-199, ....} etc... |
10-21-2010, 07:23 AM | #5 | |
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Adding a format operation, such as {series_index:0>4s:switch(....)}, doesn't help. The formatting is applied after the value is determined, which means after the functions have produced a value. The right solution is to add a function that can do arithmetic on a field. It could look something like 'compute(expression)'. Expression would be a combination of operators, constants, and 'x' to stand for the named field. This function would permit a general solution, at the cost of requiring 4 composite fields. They would look something like Code:
#index1_left:{series_index:compute(((x/100)*100)+1)} #index1_right: {#index1_left:compute(x+99)} #index2_left:{series_index:compute((((x%100)/10)*10)+1)} #index2_right:{#index2_left:compute((x+9)} template: {#genre}/{series:||/}{#index1_left:0>4s||-}{#index1_right:0>4s:||/}{#index2_left:0>4s||-}{#index2_right:0>4s:||/}{title} |
|
10-21-2010, 07:31 AM | #6 |
Grand Sorcerer
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
|
Whatever I created and lost yesterday was probably the answer to all
True, that's probably a bit too much for the average user! But there might be a simpler solution as well: #series_index_string = {series_index:0>4s} and then use that #series_index_string with the switch... {#series_index_string:switch(00\d\d,0000-0099,01\d\d,0100-0199,)} That way you don't need to manually change any columns... (I tested it, it works). |
10-21-2010, 07:37 AM | #7 | |
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
As long as you are on a roll, how would you deal with the second level of indexing? Would you use something like {#sis:switch(0.$,0000-0009,1.$,0010-0019,2.$,0020-0029,....} Last edited by chaley; 10-21-2010 at 07:46 AM. Reason: change lookup to switch |
|
10-21-2010, 07:43 AM | #8 | |
Grand Sorcerer
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
|
Quote:
|
|
10-21-2010, 07:46 AM | #9 |
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
10-21-2010, 08:09 AM | #10 | |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Quote:
{series}/{title:switch(00[0-9][0-9],0000-0099,01[0-9][0-9],0100-0199,02[0-9][0-9],0200-0299,03[0-9][0-9],0300-0399,04[0-9][0-9],0400-0499,05[0-9][0-9],0500-0599,06[0-9][0-9],0600-0699,07[0-9][0-9],0700-0799,08[0-9][0-9],0800-0899,09[0-9][0-9],0900-0999,Rest)}/{title:switch([0-9][0-9]0[0-9],00-09,[0-9][0-9]1[0-9],10-19,[0-9][0-9]2[0-9],20-29,[0-9][0-9]3[0-9],30-39,[0-9][0-9]4[0-9],40-49,[0-9][0-9]5[0-9],50-59,[0-9][0-9]6[0-9],60-69,[0-9][0-9]7[0-9],70-79,[0-9][0-9]8[0-9],80-89,[0-9][0-9]9[0-9],90-99,Rest)}/{title} Since the titles are : Perry Rhodan 0001 - First book I could also use the title for this, it works great when using this structure: 0000-0099 0000-0099/00-09 0000-0099/10-19 0000-0099/20-29 etc. 0100-0199/00-09 0100-0199/10-19 etc. Any idea to make the last folder complete so it reads like this: 0000-0099 0000-0099/0000-0009 0000-0099/0010-0019 0000-0099/0020-0029 etc. 0100-0199/0100-0109 0100-0199/0110-0119 etc. |
|
10-21-2010, 08:21 AM | #11 |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
I tried to make a column based on the title, so it would extract the number in series from it, but I can't seem to make it work.
I used this template: {title:[0-9][0-9][0-9][0-9]} thinking this would return only the number. Would love to check if the title starts with 'Perry Rhodan' and returns the number automatically. This way I can use another automatic column with only the first three characters etc. so I would have these columns: NumberInSeries1 (containing: 0001, 0002,.. 0100, 0101, etc.) (complete) NumberInSeries2 (containing: 000, 001, etc.) (tenths) NumberInSeries3 (containing: 00, 01, etc.) (hundreds) NumberInSeries4 (containing: 0, 1, etc.) (thousands) and the template would be something like: {#NumberInSeries4}000-{#NumberInSeries4}999/{#NumberInSeries3}00-{#NumberInSeries3}99/{#NumberInSeries2}0-{#NumberInSeries2}9/{title} |
10-21-2010, 12:09 PM | #12 | |||
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
{title:re( (\d\d\d\d) ,\1)} Quote:
Quote:
column nis: {title:re( (\d\d\d\d) ,\1)} column nis1: {nis:re((.)...,\1)} column nis2: {nis:re(.(.)..,\1)} column nis3: {nis:re(..(.).,\1)} column nis4: {nis:re(...(.),\1)} and the template would be something like {#nis4:||000-}{#nis4:||999/}{#nis3:||00-}{#nis3:||99/}{#nis2:||0-}{#nis2:9/}{title} |
|||
10-21-2010, 12:59 PM | #13 | |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Quote:
You are right - currently this series is the only one that has this indexing structure. (All others do not have that large a series, so the complete series can be put within one folder) I'm sorry when you don't understand me sometimes - English is not my native language. |
|
10-21-2010, 01:10 PM | #14 | |
Grand Sorcerer
Posts: 11,940
Karma: 7219261
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The template I gave you will be equal to {title} if #nis is empty, which it will be unless it finds <space><digit><digit><digit><digit><space> in the title. Achieving that is the reason that all the special characters (slash, dash) and the extra numbers are inside the {} brackets. If #nis is empty, then none of the extra characters will be included in the result. If the Perry Rhodan books are the only ones with titles containing that pattern, then you are done. If other books might accidentally have that pattern, then use the following for #nis. {title:re(Perry Rhodan (\d\d\d\d) ,\1)} Make sure that spacing in the regexp is equal to the spacing in the titles. |
|
12-16-2011, 02:22 AM | #15 |
Member
Posts: 21
Karma: 10
Join Date: Jan 2010
Device: iRex iLiad
|
Changed complete save-to-disk structure
Hello,
Using Calibre 0.8.30 I made a new function with this name: folderOnDevice: Code:
def evaluate(self, formatter, kwargs, mi, locals, val, genretext, serietext, number_in_series, max_number_in_series, aantal_menu_items): import math titletext=val try: aant_mi = int(aantal_menu_items) except: return 'aantal_menu_items is geen aantal!' if number_in_series is None: num_in_serie = 0 else: try: num_in_serie = int(number_in_series) except: num_in_serie = 0 #return 'number_in_series is geen aantal!' maxAantInSerie = 0 if num_in_serie > 0: if max_number_in_series is None: maxAantInSerie = num_in_serie else: try: maxAantInSerie = int(max_number_in_series) except: maxAantInSerie = num_in_serie # return 'max_number_in_series is niet ingevuld!' s = '' DoeBerekening = 1 if maxAantInSerie == 0: DoeBerekening = 0 if num_in_serie == 0: DoeBerekening = 0 sResult='' if DoeBerekening == 1: #Bepaal maximum diepte (aantal submenus) menudiepte = 0 while (int(math.floor(maxAantInSerie / (aant_mi ** menudiepte)))>aant_mi) and (menudiepte<10): menudiepte = menudiepte + 1 #tbv formattering op juiste aantal cijfers ac=len('{0}'.format(maxAantInSerie)) for MenuIndex in range(0, menudiepte): iPWplus1 = aant_mi**(MenuIndex+1) van = int(math.floor( (num_in_serie-1) / iPWplus1) * iPWplus1 + 1) tot = int(math.floor(((num_in_serie-1) / iPWplus1) + 1) * iPWplus1 ) if tot > maxAantInSerie: tot = maxAantInSerie sResult = '/{3} {1:0{0}}-{2:0{0}}'.format(ac, van, tot, serietext) + sResult sResult = genretext + '/' + '/' + serietext + sResult + '/' #Dubbele slashes verwijderen sResult=sResult.replace('//', '/') sResult=sResult.replace('//', '/') #Eerste slash verwijderen sResult=sResult.lstrip('/') return sResult max_number_in_series genre and two columns especially for showing the folder in which the books are kept: folder_on_device_10 Script: Code:
{title:folderOnDevice({#genre},{series},{series_index},{#max_number_in_series},10)} Script: Code:
{title:folderOnDevice({#genre},{series},{series_index},{#max_number_in_series},6)} Code:
{#folder_on_device_10:||/}{title} I see the correct name in the tree, for example the series (12 books) 'De wetten van de magie' had this in the folder_on_device column: Code:
Book 01: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 02: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 03: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 04: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 05: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 06: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 07: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 08: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 09: Fictie/De wetten van de magie/De wetten van de magie 01-10/ Book 10: Fictie/De wetten van de magie/De wetten van de magie 11-12/ Book 11: Fictie/De wetten van de magie/De wetten van de magie 11-12/ Book 12: Fictie/De wetten van de magie/De wetten van de magie 11-12/ D:\eBooks\_ExportFromCalibre\#folder_on_device_10 so, while many books go to the correct folder, these won't, even while the column is correct. (All Perry Rhodan books for instance are correctly placed in sub folders) Please, help me with this problem! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Old Thread] Folder Structure | gplauche | Calibre | 29 | 02-13-2012 05:13 PM |
Send to Device (structure) | mgmueller | Calibre | 1 | 02-21-2010 01:54 PM |
Send to device folder structure? | Slite | Calibre | 2 | 01-09-2010 05:20 AM |
Folder structure doubt | Oletros | iRex | 3 | 01-01-2009 07:00 AM |
SD Folder structure | ctitanic | Amazon Kindle | 1 | 12-30-2007 12:48 PM |