HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: grimes on 2019-03-20 13:41:43

Title: Request: Titleformat $caps3()
Post by: grimes on 2019-03-20 13:41:43
I have a feature request concerning titleformat:
$caps() converts to "Proper Case" ("Blah Blah Blah").
A useful thing to expand titleformat would be to convert to "Sentence case" ("Blah blah blah"). Only the first character of the first word in sentence is in upper case.
Title: Re: Request: Titleformat $caps3()
Post by: Coreda on 2019-03-20 14:33:09
Could use the following, no? Admittedly a dedicated function would be simpler but at least is possible currently.

Code: [Select]
$caps($left(%title%,1))$substr(%title%,2,$len(%title%)) 

or

Code: [Select]
$upper($left(%title%,1))$substr(%title%,2,$len(%title%)) 
Title: Re: Request: Titleformat $caps3()
Post by: grimes on 2019-03-20 15:23:10
It is more complicated.
Sentence case: "Blah! Blah blah"
Title: Re: Request: Titleformat $caps3()
Post by: j7n on 2019-03-20 19:32:20
You probably could write a really long script with $strstr() searching for "! ", ". ", "? ", repeat each of them about three times for multiple sentences. Insert a unique 'marker' after the punctuation mark. Capitalize at the position found. Remove the markers at the end. For operations like this, I wish we had functions. But you also lose capitalization of proper nouns.

Maybe $capss() for "sentence" is easier to remember.
Title: Re: Request: Titleformat $caps3()
Post by: Porcus on 2019-03-21 00:20:15
But you also lose capitalization of proper nouns.

Maybe $capss() for "sentence" is easier to remember.

For symmetry with $caps and $caps2, what about
$capss() does sentence capitalization and converts "everything else" to lowercase (compare $caps())
$capss2() does sentence capitalization and leaves all other letters as they are (compare $caps2())

Or $scaps / $scaps2
Title: Re: Request: Titleformat $caps3()
Post by: Tropoje on 2019-03-21 06:21:14

For symmetry with $caps and $caps2, what about
$capss() does sentence capitalization and converts "everything else" to lowercase (compare $caps())
$capss2() does sentence capitalization and leaves all other letters as they are (compare $caps2())

Or $scaps / $scaps2

Very good idea. That would be very helpful in organizing my library.
Title: Re: Request: Titleformat $caps3()
Post by: davideleo on 2019-03-21 18:29:50
It is more complicated.
Sentence case: "Blah! Blah blah"

It gets even more complicated: "The first men on the moon were the Americans. Who will be the first on Mars?"


Personally, rather than a new titleformatting function, I'd rather have one more option in the masstagger component to mimic functions, something like "FORMAT values from input dialog...".
For example, I have a masstagger script to stylize english titles according to musicbrainz rules. I wanted to use it for both track and album titles, so I had to make an exact copy of it and replace all %title% occurrences with %album% and if I wanted to use it for any other field I'd have to make a third copy (and remember to keep track of eventual edits for all three of them). Maybe there could be a special notation to replace the field indicator with the one received from an input dialog box, triggered by the command to run the script.
Title: Re: Request: Titleformat $caps3()
Post by: Daeron on 2019-03-21 20:05:13
Have you tried something like this?
Code: [Select]
$puts(mystring,%title%)
$get(mystring)
Put the first line in front, then replace all occurences of %title% in your script with the second line. Then you only have to edit one instance instead of all.

Have not tested if it actually works with masstagger, so your mileage may vary. Also obviously this is just a slight optimization of a process you probably already don't like.
Title: Re: Request: Titleformat $caps3()
Post by: Porcus on 2019-03-22 11:15:56
It gets even more complicated: "The first men on the moon were the Americans. Who will be the first on Mars?"

Sure, but if you want to do as much correct automatically first to minimize manual patchwork, then converting
the first men on the moon were the americans. who will be the first on mars?
into
The first men on the moon were the americans. Who will be the first on mars?
would be an improvement. If you are German, you need a bit more work though.

(And can someone please tell the idiots at Discogs that Capitalizing Every Word In Every Language Is Damn Wrong?)