Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-11-2018, 06:20 AM   #1
Kaimeirra
Junior Member
Kaimeirra began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: Kindle Oasis
Post Help with 'Send to Disk' template

Hi, I would like some help with my file naming template plz. I would like books with series to appear as:

Author (Series #03.00) Title

and books with no series to appear as:

Author - Title

The template I have work out so far is:

{authors} {series:ifempty(-)|(| }{series_index:0>5.2f|#|)} {title}

which makes books with series appear correctly BUT books with out a series appear as:

Author (- Title

this is due to the prefix in 'series' appearing before the command 'ifempty' for some reason, and I cant get my head around how else to place the 'ifempty' or another command to use..

ALL HELP WOULD BE MUCH APPRECIATED

ps: I know I can choose to have the file names all different/simpler but my aim of this post is to see if its possible to do as stated above.
Kaimeirra is offline   Reply With Quote
Old 03-11-2018, 07:31 AM   #2
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,161
Karma: 1404241
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Code:
{authors} {series:|(| }{series_index:0>5.2f|#|)} {series:ifempty(-)} {title}
Divingduck is offline   Reply With Quote
Advert
Old 03-12-2018, 02:31 AM   #3
Kaimeirra
Junior Member
Kaimeirra began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: Kindle Oasis
Quote:
Originally Posted by Divingduck View Post
Code:
{authors} {series:|(| }{series_index:0>5.2f|#|)} {series:ifempty(-)} {title}
Thankyou for the reply, I have tryed that template and the problem is that it works for those with out a series but for those with a series, it then displayes the series name twice..
Kaimeirra is offline   Reply With Quote
Old 03-12-2018, 07:13 AM   #4
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,161
Karma: 1404241
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Oh, my fault...

This one should work like you want
Code:
program:
contains(ifempty(field('series'),'-'),'-',template('{authors} - {title}'),template('{authors} {series:|(| }{series_index:0>5.2f|#|)} {title}'));
Remark:
Its working in program mode.
I check for series and give back series or '-' if there is no series.
contains check for '-' and use then one of the two template structures.

Not elegant but works.

Edit: Forgot to mention that you need to copy the complete string (both lines) in your template. You can do this direct or via the template editor
Attached Thumbnails
Click image for larger version

Name:	calTemp.PNG
Views:	222
Size:	46.9 KB
ID:	162761  

Last edited by Divingduck; 03-12-2018 at 07:37 AM.
Divingduck is offline   Reply With Quote
Old 03-12-2018, 12:03 PM   #5
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,430
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Divingduck View Post
Oh, my fault...

This one should work like you want
Code:
program:
contains(ifempty(field('series'),'-'),'-',template('{authors} - {title}'),template('{authors} {series:|(| }{series_index:0>5.2f|#|)} {title}'));
Remark:
Its working in program mode.
I check for series and give back series or '-' if there is no series.
contains check for '-' and use then one of the two template structures.

Not elegant but works.

Edit: Forgot to mention that you need to copy the complete string (both lines) in your template. You can do this direct or via the template editor
Looking at your code, I suspect that it will write all the books into a single directory instead of the default Author_Sort directories inside the selected Save to directory.

I suspect adding {author_sort}/ to the templates between the ' and the {author} would return to the default saving into author_sort folders.

Code:
program:
contains(ifempty(field('series'),'-'),'-',template('{author_sort}/{authors} - {title}'),template('{author_sort}/{authors} {series:|(| }{series_index:0>5.2f||)} {title}'));
Serial numbers filed off and saved for future reference....

Last edited by DNSB; 03-12-2018 at 12:22 PM. Reason: Added modified code
DNSB is online now   Reply With Quote
Advert
Old 03-12-2018, 02:24 PM   #6
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,161
Karma: 1404241
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Quote:
Originally Posted by DNSB View Post
Looking at your code, I suspect that it will write all the books into a single directory instead of the default Author_Sort directories inside the selected Save to directory.
Yes, because that was what Kaimeirra ask for at #1

Feel free to modify the code to your personal flavor/needs. It's only a example and improvements are welcome

I found a lot of inspirations in the sticky post Plugboard, template, and custom composite column recipes where @chaley, @eschwartz and a lot of users showing their interesting solutions using the calibre template language. It was worth every minute I spend for reading this thread over the years.
Divingduck is offline   Reply With Quote
Old 03-12-2018, 07:16 PM   #7
Kaimeirra
Junior Member
Kaimeirra began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: Kindle Oasis
Quote:
Originally Posted by Divingduck View Post
Oh, my fault...

This one should work like you want
Code:
program:
contains(ifempty(field('series'),'-'),'-',template('{authors} - {title}'),template('{authors} {series:|(| }{series_index:0>5.2f|#|)} {title}'));
Remark:
Its working in program mode.
I check for series and give back series or '-' if there is no series.
contains check for '-' and use then one of the two template structures.

Not elegant but works.

Edit: Forgot to mention that you need to copy the complete string (both lines) in your template. You can do this direct or via the template editor
PERFECT! Works exactly as I asked
Thanks for the concern about the folders DNSB, I am using folder sorting as well but as I knew how to add that I didnt include it in the coding I was asking help for. So this is what I am using:

program:
contains(ifempty(field('series'),'-'),'-',template('{author_sort}/{authors} - {title}'),template('{author_sort}/{series}/{authors} {series:|(| }#{series_index:0>5.2f||)} {title}'));

Sorry I dont know how to put it in a code: box

Thanks again for everyones help!
Kaimeirra is offline   Reply With Quote
Old 03-12-2018, 07:19 PM   #8
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,430
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Divingduck View Post
Yes, because that was what Kaimeirra ask for at #1

Feel free to modify the code to your personal flavor/needs. It's only a example and improvements are welcome

I found a lot of inspirations in the sticky post Plugboard, template, and custom composite column recipes where @chaley, @eschwartz and a lot of users showing their interesting solutions using the calibre template language. It was worth every minute I spend for reading this thread over the years.
I took it that his template attempts were for the filename used for the saved book and not for modifying the save to directory structure as well. Personally, I would prefer not to have 8000 or so ebooks with cover images and metadata files in one directory hence my suggested modification.

Edit: Again bitten by replying before reading the complete thread.

And yes, that thread is a great source of information. Together with the regex threads for Calibre and Sigil, among my favourite resources on Mobileread.

Last edited by DNSB; 03-12-2018 at 07:22 PM.
DNSB is online now   Reply With Quote
Old 03-12-2018, 07:21 PM   #9
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 35,430
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Kaimeirra View Post
PERFECT! Works exactly as I asked
Thanks for the concern about the folders DNSB, I am using folder sorting as well but as I knew how to add that I didnt include it in the coding I was asking help for. So this is what I am using:

Code:
program:
contains(ifempty(field('series'),'-'),'-',template('{author_sort}/{authors} - {title}'),template('{author_sort}/{series}/{authors} {series:|(| }#{series_index:0>5.2f||)} {title}'));
Sorry I dont know how to put it in a code: box

Thanks again for everyones help!
Highlight the text and click on the # (code) icon. If you are editing a message, you need to click go advanced.

Good to hear that you are a happy camper.
DNSB is online now   Reply With Quote
Old 03-13-2018, 05:32 AM   #10
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Divingduck View Post
Code:
{authors} {series:|(| }{series_index:0>5.2f|#|)} {series:ifempty(-)} {title}
This single-function-mode template gives what the OP asked for:
Code:
{authors} {series:|(| }{series_index:0>5.2f|#|)} {series:test(,  - )} {title}
Using "test" instead of "ifempty" lets us output an empty string when the series is not empty, otherwise a hyphen.
chaley is offline   Reply With Quote
Old 03-13-2018, 07:49 AM   #11
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,161
Karma: 1404241
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
@chaley, this one is elegant. Thanks
Divingduck is offline   Reply With Quote
Old 03-14-2018, 06:59 PM   #12
Kaimeirra
Junior Member
Kaimeirra began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: Kindle Oasis
Post

Quote:
Originally Posted by chaley View Post
This single-function-mode template gives what the OP asked for:
Code:
{authors} {series:|(| }{series_index:0>5.2f|#|)} {series:test(,  - )} {title}
Using "test" instead of "ifempty" lets us output an empty string when the series is not empty, otherwise a hyphen.
Wow, certainly is simple, elegant and still does exactly what Im after

I have another piece I would like some help with. Not sure if I should be starting a new thread or if Im right to continue here..

I would like my book series index to appear as:

#01 and #01.5 when I have .x in the series

at the moment I am using

Code:
{series_index:0>5.2f|#|}
which gives #01.00, so is there a way to have no trailing zeros but have the decimal and number after it appear if they exist?
Kaimeirra is offline   Reply With Quote
Old 03-14-2018, 07:43 PM   #13
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Code:
{series_index:'re(format_number($, '05.2f'), '\.00', '')'}
chaley is offline   Reply With Quote
Old 03-14-2018, 08:22 PM   #14
Kaimeirra
Junior Member
Kaimeirra began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: Kindle Oasis
Lightbulb

PERFECT



So my final template for file names, if anyone else is interested, is :

Code:
{author_sort}/{series}/{series_index:'re(format_number($, '04.1f'), '\.0', '')'|#| }{title}/{authors} {series:|(| }{series_index:'re(format_number($, '04.1f'), '\.0', '')'|#|)} {series:test(,  - )} {title}
which appears as:

Author Sort/Series/#03 Title/Author (Series #03) Title

or

Author Sort/Series/#03.5 Title/Author (Series #03.5) Title

or

Author Sort/Title/Author - Title

depending on if there is a series and if the series index has a decimal

Thank You eveyone who has helped and responded

... I might even be considering whether to reduce author to 'first letter first name and full last' so as to reduce file name size something for another time lol
Kaimeirra is offline   Reply With Quote
Reply

Tags
calibre, file names, send to disk, template


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help - Save to Disk template Gallips Calibre 8 06-28-2016 01:46 PM
Please help on a Save to Disk template Dammie Library Management 15 12-16-2013 09:51 AM
Need help on a Save to Disk template fidvo Library Management 2 08-12-2012 03:34 PM
Saving to Disk Template hurricane51 Conversion 2 07-07-2011 01:22 AM
save to disk template speakingtohe Calibre 9 05-29-2010 06:02 AM


All times are GMT -4. The time now is 03:37 PM.


MobileRead.com is a privately owned, operated and funded community.