09-18-2010, 02:10 PM | #46 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
We have three things: 1) the metadata for a book. Say we are working on 'title' 2) the search expression 3) the target expression What we do is: book.meta('title') = re.sub(search_exp, target_exp, book.meta('title')) We can't put a cross-field reference into search_exp, because then it won't match the metadata. We can put a cross-field reference into the target. Consider: book.meta('series') = re.sub('', '\g<title>', book.meta('series')) In your second example, series would now be 'BookSeries 1 Hello world'. You can now hack at it with further search/replaces. However, I don't think that is what you really want. It seems to be that you really want to be able to say something like: book.meta('series') = re.sub('(.*\d+) ', '\1', book.meta('title')) Or perhaps you want both facilities? book.meta('genre') = re.sub('(Fiction|Fantasy)', '\1 \g<#genre>', book.meta('tags')) Do I have it right? (Starson17, could you also answer this?) |
|
09-18-2010, 02:15 PM | #47 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Even though I have strong doubts that this search/replace stuff will be in the end a good thing to have done, it is technically fascinating. How best to combine the power of the new metadata management facilities (you don't have that yet -- beta soon) and the just-born search/replace stuff is the sort of challenge I like. |
|
Advert | |
|
09-18-2010, 02:58 PM | #48 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: irex iliad, htc hd2
|
It seams to me that the questions comes down to the following.
Do we need: - a one to one field copy - and remove some not needed characters - do we need to combine fields (a many to one copy) - and remove some not needed characters At this point in time, I cannot seam to find an useful example for the usage of combining fields. Something like this would only occur for something like this: - series contains: AuthorLastName - author contains: AuthorFirstName In this situation you would like to combine both fields to complete the author field. In my opinion this situation is rare. |
09-18-2010, 04:24 PM | #49 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
If no support issues arise and no one loses their library, it will have been a great thing to have done. If they do .... point to the warnings and sleep well anyway. I've also used it to do a few things I wanted to do, but not enough to do the hard way.
|
09-18-2010, 04:40 PM | #50 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Charles already has the "remove unwanted characters" built in the regex processing. All we need is two pulldown boxes for existing field references, one labeled "Source Field" and one "Destination Field" and a checkbox for overwrite/append. The code just has to check for compatible field types for the overwrite/append operation. |
|
Advert | |
|
09-18-2010, 04:54 PM | #51 |
Wizard
Posts: 3,450
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
You guys are incredible!
I have just started to use Calibre to organize some of my chronically disorganized books. I have come across situation when I realized that a bulk edit of metadata using my beloved Regular Expressions could be very useful. Then I spot this thread. Before I finish the thread I start Calibre, to try something out, and it tells me there is new version (despite the fact I updated just a few days ago). After updating Calibre, it turned out there is a sparkling new experimental feature - Search and replace in Bulk metadata edit. Absolutely incredible! |
09-18-2010, 10:44 PM | #52 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@chaley: A feature you might consider adding is a checkbox that control if the search and replace texts are interpreted as regexs or as normal strings. For people that get scared by regexs, normal S&R could still be useful.
|
09-19-2010, 01:35 PM | #53 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: irex iliad, htc hd2
|
|
09-19-2010, 04:04 PM | #54 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Folks:
In the new-metadata releases (will go to alpha today or tomorrow), I am considering implementing the following, chosen via a combo box. 1) Text mode -- case sensitive. Simple text search and replace. 2) Text mode -- case insensitive. 3) Regexp basic -- as today. Source and destination are the same. Search_string is applied to source, matches are replaced with replace_string then processed by function. 4) Regexp advanced. Source is a template, similar to the save-as templates. The source string is built from the template. Destination is explicitly specified, and must be a single field. For the destination, a combo box will offer the choices of 'replace', 'prepend', or 'append'. The search_string will be applied to the template. Matches will be replaced with replace_string and processed by function. When all matches are finished, the result will be saved to the destination according to the 'replace' etc specification. The advanced form can be used to copy values between fields with some processing on the way, construct composite fields, combine fields, and many other variations. I think this covers all the requests to date. I know it is hard to make comments without an implementation, but if you have any, speak now. |
09-19-2010, 04:32 PM | #55 | |
Wizard
Posts: 3,450
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
I can't wait to play with the new features. |
|
09-19-2010, 04:44 PM | #56 | |
Well trained by Cats
Posts: 29,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Provide the template and a "Comment/Description field(to say what it is supposed to be doing)" (balloon tip OK if there is a comment mechanism somewhere. Provide a Import/Export so we can share solutions a discard (for the times we really mess up) |
|
09-19-2010, 04:46 PM | #57 | |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
|
|
09-19-2010, 10:41 PM | #58 | |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
For those that know what they're doing this will be an annoyance, for those that aren't sure what they're doing maybe they will think twice. Keep up the excellent work. |
|
09-20-2010, 04:34 AM | #59 | |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
Seriously though, in my opinion, keep the warning as it is now, maybe a little more strongly worded. Those who are too stupid, excuse the language, to read what the window they're using says deserve no better. (I'm a fan of YAFIYGI as opposed to WYSIWYG, can you tell? ) |
|
09-20-2010, 04:50 AM | #60 | |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
For all I know there is a pop-up warning currently in addition to the warning on the tab, since I haven't tried the current experimental feature. |
|
Tags |
metadata, replace, search |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CALIBRE WILL NOT RECOGNISE TITLES OR AUTHORS | D.. | Calibre | 5 | 09-14-2010 09:33 PM |
Classic PDF titles and authors on nook? | slothrop | Barnes & Noble NOOK | 2 | 12-09-2009 09:23 PM |
Issues Editing Titles & Authors | kmvargo | Calibre | 0 | 07-05-2009 12:43 AM |
Authors/Titles different font sizes | bunjibear | Sony Reader | 6 | 03-15-2009 10:41 AM |
Changes in Titles/Authors Not Shown | Ralob | Bookeen | 20 | 04-07-2008 08:16 AM |