Hi, I have just created a customized toolbar button, which executes the next renaming function:
rename s, " >."
I would like to extend its capabilities, starting by making it capitalizes words. But after reading the included help file,
I still didn't find the right way of doing that. It should perform the same renaming routine as when the predefined
"A* A*.aaa" function is invoked.
Thanks.
Script to Capitalize Words' First Letters
Re: Script to Capitalize Words' First Letters
Just use the command id for built in functions (#138 or #126, depending on which camel case you want).
Help/Show Command ID's in menu toggles the display of the id's.
Help/Show Command ID's in menu toggles the display of the id's.
Ralph
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)
Re: Script to Capitalize Words' First Letters
I'm being able to run one script at a time, but I can't make them run simultaneously. What I have tried:
rename s, " >."; ::#138;rename s, "A123/a123";
Expected result:
"The quick brown fox jumps over the lazy dog A123"
"The.Quick.Brown.Fox.Jumps.Over.The.Lazy.Dog.a123"
Similarly, when I try to combine commands into the "Rename Special > Search and Replace" function, they are executed
separately only (without quotes):
" >. "
"A123/a123 /c"
And the one that capitalizes first letters, which I don't know.
rename s, " >."; ::#138;rename s, "A123/a123";
Expected result:
"The quick brown fox jumps over the lazy dog A123"
"The.Quick.Brown.Fox.Jumps.Over.The.Lazy.Dog.a123"
Similarly, when I try to combine commands into the "Rename Special > Search and Replace" function, they are executed
separately only (without quotes):
" >. "
"A123/a123 /c"
And the one that capitalizes first letters, which I don't know.
Re: Script to Capitalize Words' First Letters
rename s, " >."; #138; rename s, "A123/a123";
Works here. But the third command isn't even necessary. #138 will already "decapitalize" the extension.
That function (apart from the id) doesn't do that. You would need to script that.And the one that capitalizes first letters, which I don't know.
One of my scripts helped you out? Please donate via Paypal
Re: Script to Capitalize Words' First Letters
As you mentioned, after removing the "::", the command worked as expected. But I kept the last command as well, since
that "A123" from the example isn't an extension, but a starting letter from a single word that might be already capitalized and I
need it as lower case.
Could the commands be combined as well, when using the "Rename Special > Search and Replace" function? At least the allowed commands to use with it, without having to create a specific script.
that "A123" from the example isn't an extension, but a starting letter from a single word that might be already capitalized and I
need it as lower case.
Could the commands be combined as well, when using the "Rename Special > Search and Replace" function? At least the allowed commands to use with it, without having to create a specific script.
Last edited by Jack99 on 03 Jun 2020 10:18, edited 1 time in total.
Re: Script to Capitalize Words' First Letters
No, you can't combine them via the context menu entry.
One of my scripts helped you out? Please donate via Paypal
Re: Script to Capitalize Words' First Letters
To show you a way how things can be scripted...
Code: Select all
$from = " ";
$to = ".";
$exclude = "A123";
$sample = "The quick A123 brown fox jumps over the lazy dog";
$new = CapitalizeWords($sample, $exclude);
$new = replace($new, $from, $to);
// Rename item via "renameitem"
text $new;
// $exclusions must be separated by "|"
function CapitalizeWords($string, $exclusions) {
$string = recase($string, "camel");
foreach($item, $exclusions, "|", "e") {
if (strpos($string, $item, 0, 1) != -1) { $string = replace($string, $item, recase($item, "l")); }
}
return $string;
}
One of my scripts helped you out? Please donate via Paypal
Re: Script to Capitalize Words' First Letters
OK, I will try that one later.
By the way, I just noticed that if the above script is put like this:
The " rename s, X264/x264" part will have no effect at all. The only difference being the commands' order (#138 in the third place, instead the second one).
Thanks.
By the way, I just noticed that if the above script is put like this:
Code: Select all
rename s, " >."; rename s, "X264/x264"; #138;
Thanks.
Re: Script to Capitalize Words' First Letters
Of course it has an effect, but the third command will negate it...The " rename s, X264/x264" part will have no effect at all.
One of my scripts helped you out? Please donate via Paypal
Re: Script to Capitalize Words' First Letters
You are right, the "#138" command will capitalize it again.