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 04-28-2023, 08:19 PM   #1
chrisric
Member
chrisric began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Jan 2020
Device: iPhone/Voice Dream Reader
Save Template, is appending one tag to a filename possible?

Hi,

I've searched this forum and Google, I think I'm more lost now

I want to create a save template that will append one specific tag to the filename if that tag is linked to a book. All other books without tag "xyz" will not have this filename changed.

Default: {author_sort}/{title}/{title} - {authors}

Obvious: {author_sort}/{title}/{title} - {authors} - {tags}
This lists ALL tags though...

Is there a way to parse the tags field?

Thanks.

-Chris
chrisric is offline   Reply With Quote
Old 04-28-2023, 08:21 PM   #2
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Don't remember about specific tags in SFM. But this will list the first tag alphabetically and also get rid of an extra '-' when there's no tag.

{tags:sublist(0,1,&)| - |}

Last edited by ownedbycats; 04-28-2023 at 08:27 PM.
ownedbycats is offline   Reply With Quote
Advert
Old 04-28-2023, 10:55 PM   #3
chrisric
Member
chrisric began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Jan 2020
Device: iPhone/Voice Dream Reader
Quote:
Originally Posted by ownedbycats View Post
{tags:sublist(0,1,&)| - |}
Thanks ownedbycats.

Using {tags:sublist(0,1,&)| - |} produces the same result as {tags}

I searched "Reference for all built-in template language function" and found nothing specific to tags that might work. Of course, I have no idea if any of the other functions may work.

I guess I could save the file with {tags} and use an external script to rename the file. I'd prefer that being a last resort though.
chrisric is offline   Reply With Quote
Old 04-29-2023, 09:27 AM   #4
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: 12,444
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Don't remember about specific tags in SFM. But this will list the first tag alphabetically and also get rid of an extra '-' when there's no tag.

{tags:sublist(0,1,&)| - |}
Quote:
Originally Posted by chrisric View Post
Thanks ownedbycats.

Using {tags:sublist(0,1,&)| - |} produces the same result as {tags}

I searched "Reference for all built-in template language function" and found nothing specific to tags that might work. Of course, I have no idea if any of the other functions may work.

I guess I could save the file with {tags} and use an external script to rename the file. I'd prefer that being a last resort though.
Read up on the list functions. They all work on tags.

The separator for tags is a comma, not an ampersand. As said in Using functions in templates - Single Function Mode (SFM), you enter a literal comma using \,
Code:
{tags:sublist(0,1,\,)}
The following template in Template Program Mode (TPM), is easier to understand (for me at least):
Code:
{tags:'sublist($, 0, 1, ',')'| - |}
However, you appear to be asking to test for the existence of a particular tag. That can be done by embedding General Program Mode (GPM) into TPM
Code:
{tags:'if '^xyz$' inlist $tags then 'xzy' fi'| - |}
If for some reason you don't want to embed GPM then this "pure" TPM template does it:
Code:
{tags:'in_list($, ',', '^xyz$', 'xyz', '')'| - |}
chaley is offline   Reply With Quote
Old 04-29-2023, 09:57 AM   #5
chrisric
Member
chrisric began at the beginning.
 
Posts: 15
Karma: 10
Join Date: Jan 2020
Device: iPhone/Voice Dream Reader
wow, thanks chaley.

I used the GPM version, I can even understand it once you spelled it out for me. I also tried the TPM version, they both work perfectly.

I really appreciate the help.

Cheers,
-Chris
chrisric is offline   Reply With Quote
Advert
Old 04-29-2023, 12:52 PM   #6
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,970
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Oops, sorry - I copied the sublist from an author_sort and forgot to change the separator.
ownedbycats is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Request: Match Calibre Filename template recipe cbook7 Library Management 10 06-05-2020 05:11 AM
Download Filename Template? nqk Server 2 06-02-2020 04:19 AM
Template for folder/filename for Author/Title with Chinese characters ctop Library Management 2 02-07-2020 07:37 AM
Change filename template in Calibre's library 8140david Library Management 3 09-25-2016 11:39 AM
filename template feature artbatista Calibre 0 08-23-2009 01:05 PM


All times are GMT -4. The time now is 05:38 PM.


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