![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28
Karma: 100000
Join Date: Mar 2010
Device: Kindle PW4, Sony PRS-T1, PRS-600 & Nook STR
|
Replacing characters with the save to disk template
I have been trying to figure out how to use the saving books to disk template.
When I save a book that is named something like: Mark Twain - Anthologies: How Many Are There? I would like to replace the colon with a semicolon and remove the question mark so that it comes out as this: Mark Twain - Anthologies; How Many Are There Is there a way to achieve that? This is all I've been able to work out so far. Code:
Replace ? with nothing {authors} - {title:re(\?,)} -------------------------------------------------------- Replace ? and : with nothing {authors} - {title:re(\?|\:,)} -------------------------------------------------------- Replace : with ; {authors} - {title:re(:,;)} I'd also like to possibly add to it if I need to change other special characters to something other than an underscore. Thanks for any help. |
![]() |
![]() |
![]() |
#2 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,515
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: t = $title; t = re(t, '\?', ''); t = re(t, ':', ';'); # Add any more changes that you want. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28
Karma: 100000
Join Date: Mar 2010
Device: Kindle PW4, Sony PRS-T1, PRS-600 & Nook STR
|
Thank you for responding. I plugged this into the template editor in saving books to disk:
Code:
program: t = $title; t = re(t, '\?', ''); t = re(t, ':', ';'); # Add any more changes that you want. I was hoping to have an output of the author and title like this: Author - Title I can't figure out how to add the author to your code. Thanks again. |
![]() |
![]() |
![]() |
#4 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,515
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Use: Code:
program: # The authors a = $authors; # Do any transforms you want to authors # For example, to get the first author # a = list_item(a, 0, '&'); # The title t = $title; t = re(t, '\?', ''); t = re(t, ':', ';'); # Add any more changes that you want. # Construct the final output a & ' - ' & t |
|
![]() |
![]() |
![]() |
#5 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28
Karma: 100000
Join Date: Mar 2010
Device: Kindle PW4, Sony PRS-T1, PRS-600 & Nook STR
|
Quote:
EXCEPTION: Formatter: Failed to scan program. Invalid input '& ' - ' & t' near the end of the program I'm not sure if I needed to change something in the code or not. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,515
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: # The authors a = $authors; # Do any transforms you want to authors # For example, to get the first author # a = list_item(a, 0, '&'); # The title t = $title; t = re(t, '\?', ''); t = re(t, ':', ';'); # Add any more changes that you want. # Construct the final output strcat(a, ' - ', t) |
|
![]() |
![]() |
![]() |
#7 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28
Karma: 100000
Join Date: Mar 2010
Device: Kindle PW4, Sony PRS-T1, PRS-600 & Nook STR
|
Sorry, I didn't realize it had been so long since I updated Calibre.
This is exactly what I'm looking for. Thank you for your time and help. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Save to Disk Template | Amanda5177 | Library Management | 8 | 01-09-2019 01:09 PM |
save to disk template help | bilaly | Library Management | 2 | 10-19-2018 07:19 PM |
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 |
save to disk template | speakingtohe | Calibre | 9 | 05-29-2010 06:02 AM |