View Single Post
Old 06-10-2024, 10:48 PM   #9
Bozana
Bozana
Bozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beautyBozana does all things with Zen-like beauty
 
Bozana's Avatar
 
Posts: 28
Karma: 32224
Join Date: Jan 2013
Device: PC
Thumbs up

Quote:
Originally Posted by chaley View Post
You can do this with Bulk metadata edit / Search & replace using "template" as the source.
  1. Backup your library in case things go pear shaped.
  2. Select all the books you want to change.
  3. Go to Bulk metadata edit, search & replace tab. Make it look like the following:
    Attachment 208788

    The template code is:
    Code:
    python:
    def evaluate(book, context):
    	import re
    	nt = []
    	for w in re.split(r'([ _.()])', book.get('title')):
    		nt.append(w.capitalize())
    	return ''.join(nt)
    The r'([ _.()])' is the list of letters that separate words to be capitalized. This choice may not be the best for your library. You might want to add more letters. You could use r'(\W)', all non-alphabetic letters, but this might do the wrong thing with words like "_aaa" (aaa would not be capitalized) or "a.b" (b would not be capitalized). The choice depends on how much cleanup is required. Personally, I would use r'(\W)' and clean up the odd wrong title.

    If you change the template you can test it on some books using the template editor before running it in Search & replace.
  4. Press OK. Wait. Changing titles requires writing the disk, which can take some time.
  5. Check the results. If they aren't what you want then restore the backup.

O

EDIT: This template uses the python title() function to "Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase." It does a better job in some cases but suffers from changing words like "isn't" to "Isn'T".
Code:
python:
def evaluate(book, context):
	return book.get('title').title()
Oh my goodness! Thank you so very, very much! This has been bothering me for years! I'm lvl 2 autistic and and old fashioned. I grew up with books that had Proper Case on book covers, in the 70's. So much appricated and I'm beyond grateful! xoxoxo

And yes it works and I'm so happy! You've made my day!
Bozana is offline   Reply With Quote