Revisiting $title / Smart Title Case, Join Words and All That

Tags: #<Tag:0x00007f00c3960378>

Looking for information about Title Case, join words and All that Kind of Stuff… (See this thread)

…and the Smart Title Case plugin, but since you can’t actually see the results from the plugin until after it’s saved? … and it only works on certain tags while $title works on whatever you’ve passed to it.

I want to see it -NOW- … not later so I started thinking … what if $title would do the same thing as Smart Title Case and retains the embedded UPPER CASE but Would Otherwise Do The Rest Of The Text As Desired, and since Smart Title Case Is Also Supposed to Deal With the join words…

Yeah, that sounds like it would be cool, let’s try it!

One thing turned to another and … after some google fu … I thought I’d try and just use something already out there…

$set(title,$titlecase(%title%))`
               ^
                \ <--- New Scripting Function:

This test sentence:

“the word is EAT THIS NOW. USA. USB. US VS us. the big bad fire truck is going to eat you! abba & ac/dc are playiNG on a Farm down by the river”

will become this:
“The Word Is Eat This Now. Usa. Usb. US vs Us. The Big Bad Fire Truck Is Going to Eat You! ABBA & AC/DC Are Playing on a Farm Down by the River”

Words in the list to keep capitalized will stay capitalized as long as they’re not the last word.

if word.upper() in ('USA', 'US', 'ABBA', 'AC/DC'):`

I’m definitely in the “Know enough to be dangerous” category with Python, so I’m totally blown away that this thing actually works, and it even worked the First Time I Tried It! … that’s a first first. Woohoo!

Perhaps it should be a plugin, but the only way I can think to do it would be the “clever hack” type like the one that ads the Artist Column… that you “can’t” disable.

I added it to the the code base:

The list of ‘keepwords’ would go nicely in an Options: Scripting … Words to Keep CAPS dialog.
But that’s still out of my league at this time. So…

Smart Title Case for any Tag:

$set(title,$titlecase(%title%))
$set(artist,$titlecase(%artist%))
$set(album,$titlecase(%album%))
$set(artistsort,$titlecase(%artistsort%))
$set(albumsort,$titlecase(%albumsort%))
$set(albumartistsort,$titlecase(%albumartistsort%))
$set(label,$titlecase(%label%))

…and ‘feat’ stays lower case too!