How to Capitalize Contents of the Clipboard?
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
How to Capitalize Contents of the Clipboard?
Rename Special:
#146: Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched.
Tried something like ::#146 "<clipboard>"; but no go. Help, please...?
#146: Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched.
Tried something like ::#146 "<clipboard>"; but no go. Help, please...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: How to Capitalize Contents of the Clipboard?
#146; is for renaming file names.. it does not operate on strings.
Your current best bet is probably to use replacelist:Of course this particular code does not cover accented or extended characters, consider that an exercise to lessen your dependence on the forum scriptwriters. 
Edited to make note that ReplaceList is a function and will return the converted string.
Your current best bet is probably to use replacelist:
Code: Select all
$convertedString = ReplaceList("<clipboard>","abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ",,1);Edited to make note that ReplaceList is a function and will return the converted string.
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
TheQwerty:
Attempts on those stuff still results in nothing:
-WinRAR Unpack Level Checker: previous comments relating to the request can be found here and also I believe this code can be used as it's good for the moving part of process. But I simply can't put those stuff together.
-Catalog Maker, which is partially done here despite my (copy and paste) solution being very limited due to having to a) manually check each and every subfolder and b) having to delete some stuff manually (which I did for "all files" but not for "selected files" as for option here. I *can't* script.
-Name Replacer sounds quite simple. My attempts were disastrous, though.
-Remissive Index Builder sounds a nightmare...
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...).
Believe me: sometimes I search, try-and error, copy-and-paste and... nothing. Greek to me, unfortunately....consider that an exercise to lessen your dependence on the forum scriptwriters.
Attempts on those stuff still results in nothing:
-WinRAR Unpack Level Checker: previous comments relating to the request can be found here and also I believe this code can be used as it's good for the moving part of process. But I simply can't put those stuff together.
-Catalog Maker, which is partially done here despite my (copy and paste) solution being very limited due to having to a) manually check each and every subfolder and b) having to delete some stuff manually (which I did for "all files" but not for "selected files" as for option here. I *can't* script.
-Name Replacer sounds quite simple. My attempts were disastrous, though.
-Remissive Index Builder sounds a nightmare...
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...).
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: How to Capitalize Contents of the Clipboard?
This might work beyond the standard A through Z.. I don't care much for thinking about letters beyond those, so it's also extremely likely that this won't work at all...
Code: Select all
"To Upper Hack"
$cb = "<clipboard>";
$result = "";
$i = 0;
$len = StrLen("$cb");
while ($i < $len) {
$charL = SubStr("$cb", $i, 1);
$charU = chr(asc("$charL")-32);
if ("$charU" LikeI "$charL") {
$result = "$result$charU";
} else {
$result = "$result$charL";
}
$i = $i + 1;
}
Text("$result");-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Errr...
#146 stands for "Aaa Aa.*".
Thanks, anyway - may help someone else (that's why this is all done in public, and not via PM...).
-sorry on my part if I forgot to mention that.
#146 stands for "Aaa Aa.*".
Thanks, anyway - may help someone else (that's why this is all done in public, and not via PM...).
-sorry on my part if I forgot to mention that.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Interesting thread on the same problem...
Complex name edit - RegExp or Script?
-it proves that a "0" is not an "O" nor a ".".

Complex name edit - RegExp or Script?
-it proves that a "0" is not an "O" nor a ".".
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: How to Capitalize Contents of the Clipboard?
First i understood this wrong, so my script handles line breaks too.SkyFrontier wrote:Rename Special:
#146: Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched.
Tried something like ::#146 "<clipboard>"; but no go. Help, please...?
Seconds this works only for plain english chars.
Third i messed my script up and i think it's not well written, but at least it works (for me).
It does the same as "A* A*.*", #128; "Capitalize each word in the name(s). Set all non-first letters to lower case. Leave the extension untouched."
At least it looks alike.
Test this script with care.
FROM:
This is #an (long) file name -with [some brackets] and {an} extension.ext
TO:
This Is #An (Long) File Name -With [Some Brackets] And {An} Extension.ext
DO:
Code: Select all
//input string from the clipboard:
$a = "<clipboard>";
//split into base name and extension:
$base = regexreplace($a, "(.+)(\..+)", "$1");
$ext = regexreplace($a, "(.+)(\..+)", "$2");
//now works with $base:
//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."
$L=1;
$Out="";
$temp2="";
$FirstCharStart=0;
$FirstCharNonChar="";
while(1)
{
//get every word at an space:
$word = gettoken($base, $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 = replace($Out$ext, " ".$ext, $ext);
text $Out;
//copytext $Out;
.
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Randomly picked this as input:
and had this as an output:
Thought the problem was with the "/", but this
results in this
-is it supposed to work ONLY with files?
Thank you, Stefan!
Code: Select all
Next time you could update/post anything elseCode: Select all
Next Time You Could Update/post Anything ElseNext time you could update/post anything elseCode: Select all
Next time you could updateCode: Select all
Next Time You Could UpdateNext time you could updateThank you, Stefan!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Quick dumb fix (can't tell if this affects the whole script in unpredictable ways; it just works with simple sentences; not tested against file names):
-but leaves an undesired blank space at the ending of the output... 
Code: Select all
// $Out = replace($Out$ext, " ".$ext, $ext);
$Out = replace($Out, " ".$ext, $ext);New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: How to Capitalize Contents of the Clipboard?
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:
------- 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
.
"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
.
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Stefan:
Thank you, Stefan! Works like a dream!
-oooo, how BAD of you! tsc, tsc...Arrg, now there is an blank missed from each line at the end![]()
Thank you, Stefan! Works like a dream!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Re: How to Capitalize Contents of the Clipboard?
Code: Select all
v9.50.0001 - 2010-09-09 11:15
+ Scripting got a new function.
Name: recase
Action: Changes the case of a string.FROM:
"Regarding your solution: thanks, this will help a lot with english-based names, but it's quite hard"
TO:
Regarding Your Solution: Thanks, This Will Help A Lot With English-Based Names, But It's Quite Hard
You can use now:
Code: Select all
$A = "Regarding your solution: thanks, this will help a lot with english-based names, but it's quite hard";
$B = recase($A, "Title");
text $B;EDIT:
Code: Select all
v9.50.0002 - 2010-09-12 18:53
! SC recase with "title" argument did not count line breaks as word
delimiters. Fixed. Example:
::text recase("tEXT<crlf>tEXT", "title"); //Text¶¶Text
- - -
Some example:
$ITEM = "Frozen Rain - Music Keeps Me Alive.mp3";
text recase($ITEM, "lower"); //> frozen rain - music keeps me alive.mp3
Code: Select all
//Sentence Case:
// "Music Keeps Me Alive" >>> "Music keeps me alive"
$TITLE = recase(substr($TITLE, 0, 1),"upper" . recase(substr($TITLE, 1), "lower");Code: Select all
$ITEM = "Frozen Rain - Music Keeps Me Alive.mp3";
$ARTIST = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$1");
$TITLE = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$2");
$EXT = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$3");
//Sentence Case:
$TITLE = substr($TITLE, 0, 1) . recase(substr($TITLE, 1), "lower");
msg "$ARTIST - $TITLE.$EXT"; //> Frozen Rain - Music keeps me alive.mp3Code: Select all
$ITEM = "FROZEN_RAIN_-_Music_Keeps_Me_Alive.mp3";
$ITEM = replace($ITEM, "_", " ");
$ARTIST = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$1");
$TITLE = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$2");
$EXT = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$3");
$ARTIST = recase($ARTIST, "title");
$TITLE = substr($TITLE, 0, 1) . recase(substr($TITLE, 1), "lower");
text "$ARTIST - $TITLE." . recase($EXT, "upper"); //> Frozen Rain - Music keeps me alive.MP3Code: Select all
//Invert case:
$ITEM = "FROZEN RAIN - Music Keeps Me Alive.mp3";
$LOOP=0;
$OUT="";
while(1)
{
$TOKEN = substr($ITEM, $LOOP, 1);
If ($TOKEN==""){break;}
$ASC = asc($TOKEN);
If ( $ASC > 64 && < 91 ){ $TOKEN = chr( $ASC + 32 );}
If ( $ASC > 96 && < 123){ $TOKEN = chr( $ASC - 32 );}
$OUT = $OUT$TOKEN;
incr $LOOP;
}
text $OUT; //> frozen rain - mUSIC kEEPS mE aLIVE.MP3
Last edited by Stefan on 14 Sep 2010 07:52, edited 1 time in total.
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: How to Capitalize Contents of the Clipboard?
Hi, Stefan!
I was testing and trying to adapt your solutions as a "new-user friendly" script. But... get myself in trouble, too! lol
As follows:
-Isn't "curitem" supposed to deal with (and OUTPUT) content WITHOUT the path?
-how to actually rename the items in the files themselves? (Original name should be stored anywhere then renamed as intended - how?)
-how to apply such codes into a multiple selection?
Thank you!
I was testing and trying to adapt your solutions as a "new-user friendly" script. But... get myself in trouble, too! lol
As follows:
Code: Select all
$A = <curitem>;
$B = recase($A, "Title");
copytext $B; // frozen rain - music Keeps me Alive.Mp3 >> Frozen Rain - Music Keeps Me Alive.Mp3
Output:
C:\Temp\Test_Folder\Frozen Rain - Music Keeps Me Alive.Mp3
----------
$ITEM = <curitem>;
$ARTIST = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$1");
$TITLE = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$2");
$EXT = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$3");
//Sentence Case:
$TITLE = substr($TITLE, 0, 1) . recase(substr($TITLE, 1), "lower");
copytext "$ARTIST - $TITLE.$EXT"; // Frozen Rain - Music Keeps Me Alive.mp3 >> Frozen Rain - Music keeps me alive.mp3
Output:
C:\Temp\Test_Folder\Frozen Rain - Music keeps me alive.mp3
----------
$ITEM = <curitem>;
$ITEM = replace($ITEM, "_", " ");
$ARTIST = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$1");
$TITLE = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$2");
$EXT = regexreplace($ITEM, "(.+) - (.+)\.(.+)", "$3");
$ARTIST = recase($ARTIST, "title");
$TITLE = substr($TITLE, 0, 1) . recase(substr($TITLE, 1), "lower");
$c = text "$ARTIST - $TITLE." . recase($EXT, "upper"); // FROZEN_RAIN_-_Music_Keeps_Me_Alive.mp3 >> Frozen Rain - Music keeps me alive.MP3
copytext $c
Output:
text "C:\Temp\Test_Folder\Frozen Rain - Music keeps me alive.mp3."MP3
----------
//Invert case:
$ITEM = <curitem>;
$LOOP=0;
$OUT="";
while(1)
{
$TOKEN = substr($ITEM, $LOOP, 1);
If ($TOKEN==""){break;}
$ASC = asc($TOKEN);
If ( $ASC > 64 && < 91 ){ $TOKEN = chr( $ASC + 32 );}
If ( $ASC > 96 && < 123){ $TOKEN = chr( $ASC - 32 );}
$OUT = $OUT$TOKEN;
incr $LOOP;
}
copytext $OUT; // FROZEN_RAIN_-_Music_Keeps_Me_Alive.mp3 >> frozen rain - mUSIC kEEPS mE aLIVE.MP3
Output:
c:|Temp|Testfolder|frozenrain-mUSICkEEPSmEaLIVE.MP3.MP3
-how to actually rename the items in the files themselves? (Original name should be stored anywhere then renamed as intended - how?)
-how to apply such codes into a multiple selection?
Thank you!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
XYplorer Beta Club