Page 1 of 1

How to capitalize first letter of each word

PostPosted: Tue Feb 20, 2018 8:01 pm
by gacapp
Great Utility!! Use it all the time. Can someone show me how to change the first letter of each word in a file name.

So if I have for example:

rock and roll all nite

How can I change it to:

Rock And Roll All Nite


Any help would be greatly appreciated!!

Re: How to capitalize first letter of each word

PostPosted: Wed Feb 21, 2018 2:01 am
by Admin
Hi, you can use this Javascript function in BRU:

Code: Select all
function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

newName = toTitleCase(name)

Re: How to capitalize first letter of each word

PostPosted: Wed Feb 21, 2018 5:43 pm
by therube
14:Case -> Title, may handle what you need.

Re: How to capitalize first letter of each word

PostPosted: Thu Feb 22, 2018 12:58 am
by Admin
Yes, that too :) :shock: :oops:

Re: How to capitalize first letter of each word

PostPosted: Sun Jul 14, 2019 4:47 pm
by YiannisKan
Can you please adjust the code so it can capitalize all first letters of all words ?

Re: How to capitalize first letter of each word

PostPosted: Mon Jul 15, 2019 8:55 pm
by therube
14:Case -> Title, may handle what you need.

Re: How to capitalize first letter of each word

PostPosted: Tue Apr 12, 2022 8:57 pm
by r0tt3nnn
For anyone trying to find this answer in 2022, know that the Case functionality now has its own section - Section 4.

Image

Re: How to capitalize first letter of each word

PostPosted: Mon Apr 25, 2022 7:57 am
by spamwisegamgee
r0tt3nnn wrote:For anyone trying to find this answer in 2022, know that the Case functionality now has its own section - Section 4.

Image


Just dropping in to let you know that as a guy who was wondering in 2022 and stumbled across this post, you helped. Thank you.