12-23-2021, 01:48 PM | #1 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
Search & Replace with current date
I hope someone can help me or direct me to info that can help me (nothing I've found so far has made ANY sense to me).
When I have a new book, I put on the title page "Last Read: N/A" since I haven't read it before. After reading, I have up to six Saved Searches that I run to modify lines in my title page. It would make things quicker (simpler) if I could just add changing N/A to the current date when I run the saved searches, but I can't figure out how to do it. I've spent the past 2 hours (and that's just today's attempt) but I've given up and decided to ask for help. |
12-23-2021, 02:05 PM | #2 |
Well trained by Cats
Posts: 29,944
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Where are you trying to do this?
Title page implies this Q should be moved to Editor (I can do that for you. PM me) on a per book basis If you are using a Template: today() |
Advert | |
|
12-23-2021, 03:15 PM | #3 |
Well trained by Cats
Posts: 29,944
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Check the Editor Help page for REGEX functions (it is one of the Modes on the S&R section)
One of those might help |
12-23-2021, 03:25 PM | #4 |
Well trained by Cats
Posts: 29,944
Karma: 55705602
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
You might consider making a custom version of: C:\Program Files\Calibre2\app\resources\jacket And place it in resources\jacket in the Configuration folder. That location overrides the Program files version without getting replaced every update. Then you just Embed Metadata (That updates the Jacket) and not fool around with the Editor |
12-23-2021, 03:38 PM | #5 |
Zealot
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
Search:
Code:
Last Read: \K(N/A) Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): from datetime import datetime return datetime.now().strftime("%d/%m/%Y") |
Advert | |
|
12-24-2021, 03:37 PM | #6 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
Thank you so much @lomkiri. Do you know I tried that exact code several times? But everything I read had:
from datetime import datetime before the def replace... part. No wonder I could not get it to work. So annoying. Again, thanks! |
12-24-2021, 05:00 PM | #7 |
Zealot
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
Very strange that it didn't work for you, because this code is working all right for me
Code:
from datetime import datetime def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): return datetime.now().strftime("%d-%m-%Y") |
12-24-2021, 05:11 PM | #8 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
Actually, I just figured it was because I didn't have brackets on my search string. It's the only other thing if the placement doesn't affect it. Of course I was more focussed on figuring out the replace part. It would find it fine, but instead of putting in the date, it would rewrite "%d/%m/%Y"
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with a search&replace | ownedbycats | Library Management | 3 | 03-08-2021 04:53 PM |
Search & Replace changes in 3.0 | Phssthpok | Editor | 4 | 06-21-2017 04:04 AM |
Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 07:10 PM |
Search & Replace Help | paulfiera | Conversion | 7 | 08-06-2015 03:52 AM |
Search & Replace :help: | krussell | Calibre | 3 | 08-02-2011 04:45 PM |