Maybe i have not understood it correctly, but regarding to
"Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched."
i had modified my script to work now (07 Sep 2010 21:34) on file names,
which are split into base name and extension.
So please make it clear: should this script works for
a) file-name.ext
b) just any multi line string
If b we just drop this "split file name into base and ext"-part
FROM:
Next time you could update/post anything else
TO:
Next Time You Could Update/post Anything Else
this should work. But not for all cases and without error handling:
Code: Select all
//It does the same as "A* A*.*" Special renaming, #128;
//"Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched."
//input string from the clipboard:
$a = "<clipboard>";
$L=1;
$Out="";
$temp2="";
$FirstCharStart=0;
$FirstCharNonChar="";
while(1)
{
//get every word at an space:
$word = gettoken($a, $L, " ");
If ($word ==""){break;}
//Handles ",[,(,{ etc as first char:
$FirstChar = substr($word, $FirstCharStart, 1);
If (asc("$FirstChar") > 32 && asc("$FirstChar") < 65){ $FirstCharNonChar = $FirstChar; $FirstCharStart = $FirstCharStart+1;}
If (asc("$FirstChar") > 90 && asc("$FirstChar") < 96){ $FirstCharNonChar = $FirstChar; $FirstCharStart = $FirstCharStart+1;}
If (asc("$FirstChar") > 122 && asc("$FirstChar") < 127){ $FirstCharNonChar = $FirstChar; $FirstCharStart = $FirstCharStart+1;}
//get first char and the rest of the word:
$FirstChar = substr($word, $FirstCharStart, 1);
$Rest = substr($word, $FirstCharStart+1, 255);
//If the first char has an ascii code between 97 and 122 (a-z) convert hem to upper case:
If (asc("$FirstChar") > 96 && < 123){$FirstChar = chr(asc("$FirstChar")-32);}
//If (asc("$FirstChar") > 96 && asc("$FirstChar") < 123){$FirstChar = chr(asc("$FirstChar")-32);}
//Store this result:
$temp1 = "$FirstCharNonChar$FirstChar$Rest ";
//-----------------------------------------------------------------------------------------
//if the word token contains an line break handle the word after this line break:
$LB = strpos($word, "<crlf>");
If ($LB > 0)
{
$temp1 = substr($temp1, 0, $LB+2);
$word2 = substr($word, $LB+2, 255);
$FirstChar2 = substr($word2, 0, 1);
$Rest2 = substr($word2, 1, 255);
If (asc("$FirstChar2") > 96 && < 123){$FirstChar2 = chr(asc("$FirstChar2")-32);}
$temp2 = "$FirstChar2$Rest2 ";
}
$Out = $Out$temp1$temp2;
//-----------------------------------------------------------------------------------------
$temp1="";
$temp2="";
$FirstCharStart=0;
$FirstCharNonChar="";
incr $L;
}
$Out = regexreplace($Out, "(.+) ", "$1");
text $Out;
//copytext $Out;
------- Test:
FROM:
Regarding your solution: thanks, this will help a lot with english-based names, but it's quite hard
to build a dictionary for all possible combinations in my native language. I did something like this
earlier this year, but soon I realized that the job would require an extra patience I was not able to provide for such
task (all I do with *my files* do not involve diacritics at all. Problem comes with someone else's/online stuff...).
TO:
Regarding Your Solution: Thanks, This Will Help A Lot With English-based Names, But It's QuiteHard
To Build A Dictionary For All Possible Combinations In My Native Language. I Did Something LikeThis
Earlier This Year, But Soon I Realized That The Job Would Require An Extra Patience I Was Not Able To Provide ForSuch
Task (All I Do With *My Files* Do Not Involve Diacritics At All. Problem Comes With Someone Else's/online Stuff...).
Arrg, now there is an blank missed from each line at the end
.