![]() |
#1 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
Copy date from Title to Pubdate field
I have a significant number of items in my various Calibre databases that are periodicals. The way I catalog them is to have the name of the publication and the year-Month of publication in the title field (E.g. National Geographic [1994-04].)
What I am trying to figure out, is there any way extract the [1994-04] and use that to make the entry in the published field as "Apr 1994." I spend a fair amount of time getting the title field correct, and would really like to be able to automate this part. RLH3 |
![]() |
![]() |
![]() |
#2 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,721
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Can't help with automate at add time, that probably needs the Actions Chain plugin.
However, you should be able to make use of the Bulk Metadata Edit->Search and replace tool's Regular expression mode to deal with existing books. Maybe a Saved MDE S&R spec can be used in an Action Chains script. BR |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
My workflow would not allow it to be done at the point of adding the books to the database. I add them, then there is a fairly extensive editing process to clean everything up (and checking the information against published indices of the magazines in question.)
I guess what I was hoping for was someone who has a clue with RegEx would be able to come up with something that I could use during the editing process as a saved S&R. rlh3 |
![]() |
![]() |
![]() |
#4 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,721
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
FWIW in my Periodicals library, I put the publication name in Title - e.g. "The Atlantic", Granta" etc , and the issue date in a custom column — #issue_date/Issue date formatted as YYYY MMMM. If I wanted a composite containing both title and #issue_date I'd create one with a template- {title} {#issue_date).
Yes I have duplicate titles, but Calibre can handle that okay. Can't remember why I created a custom columns for the issue date rather than use pubdate. IMO it is better to store data in the lowest form that makes sense… it's why Lego works. BR Last edited by BetterRed; 12-31-2024 at 07:46 PM. |
![]() |
![]() |
![]() |
#5 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
I understand where you are coming from, but I have 30-40000 issues already formatted and in my libraries (I collect scans of comics and pulps in addition to magazines) and I really do not want to have to go back and change all of those.
I probably could have designed this whole thing better in the first place, but what I've got works for me. As I mentioned up-thread, I am hoping that someone who understands RegEx well will take pity on me and help me out with this. rlh3 |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I believe Calibre will accept any valid date format. You set the Display format it Tweeks.
National Geographic [1994-04] Test this in the MDE bulk mode S&R REGEX search {title} .+?\s[(\d\d\d\d-\d\d)] Replace {pubdate} \1 That should populate Published. If that does not work try Replace \1-01 (pads with day 1) Cleanup pass if wanted search {title} (.+?)\s[\d\d\d\d-\d\d] Replace {title} NOTE I moved the ( ) pair |
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
ducks:
Both options give me an "Unknown string format: National Geographic [1889-04]" The date format of the published (pubdate) field is already set to the correct format (mmm yyyy) rlh3 Code:
calibre, version 7.19.0 ERROR: Failed: Unknown string format: National Geographic [1889-04] Traceback (most recent call last): File "calibre\gui2\dialogs\metadata_bulk.py", line 198, in do_it File "calibre\gui2\dialogs\metadata_bulk.py", line 535, in do_all File "calibre\db\cache.py", line 85, in call_func_with_lock File "calibre\db\cache.py", line 1636, in set_field File "calibre\db\write.py", line 568, in set_books File "calibre\db\write.py", line 568, in <dictcomp> File "calibre\db\write.py", line 81, in adapt_date File "calibre\utils\date.py", line 138, in parse_only_date File "calibre\utils\date.py", line 114, in parse_date File "dateutil\parser\_parser.py", line 1368, in parse File "dateutil\parser\_parser.py", line 643, in parse dateutil.parser._parser.ParserError: Unknown string format: National Geographic [1889-04] |
![]() |
![]() |
![]() |
#8 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Sorry, that was my best guess (I don't normally do dates that way).
Maybe one of the developers will step in. |
![]() |
![]() |
![]() |
#9 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
Ducks:
Just for fun this morning I tried running what you gave me but sent the result to the comments field and it pasted the entire title field (E.g. National Geographic [1994-04]) rather than just the date. Is there a way to make the search more selective? rlh3 |
![]() |
![]() |
![]() |
#10 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
There are REGEX tutorials here on MR. That is where I learned what I do.
Calibre (and Sigil) use the PCRE dialect. There is also a link to a REGEX cheatsheet, just remember The PCRE does not support all those. \d is a digit .+? is a not greedy wild card for 1 or more characters \s is any kind of space S the wild card should stop at the first space ![]() [A-Z], [0-9] is a range AFAIK it should have been treated as a literal in this case |
![]() |
![]() |
![]() |
#11 |
Connoisseur
![]() Posts: 57
Karma: 10
Join Date: Jul 2012
Device: iPad
|
Escaping the brackets and the dash solved the problem.
Thank you very much for your help on this, you have just saved me many, many hours of work. rlh3 |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Split pubdate from Title field into custom column | nano5 | Library Management | 0 | 05-19-2024 06:11 AM |
Format field pubdate | Jacko4237 | Kobo Reader | 2 | 04-17-2024 06:26 AM |
Automatically Setting Date field to file creation date when importing. | Marc_G2 | Library Management | 6 | 07-25-2020 10:35 PM |
Copy data from Title field to IDs field | rlh3 | Library Management | 9 | 09-24-2012 08:12 AM |
Search/Replace from Title Field to Pubdate | TMSxMR | Library Management | 5 | 08-06-2012 03:40 AM |