Thanks Biggynuff for sharing that!
Please note that the forum have eaten the leading blanks and so your script will not work for newbies without modification.
You may edit your post and add some more spaces to all the not-the-first-line-in-script lines?
livelike, please see if this will aid U:
livelike wrote:
1. an exception so that the dots or periods between two numbers should NOT be replaced (should be left as they are).
Try
//preserve dots between digits by masking them first:
FROM:
"XYplorer.Portable.File.Manager.v9.90.001"
TO:
"XYplorer Portable File Manager v9.90.001"
Code: Select all
$base = "XYplorer.Portable.File.Manager.v9.90.001";
//*** user specific setting,
//preserve dots between digits by masking them first:
$base = regexreplace($base, "(\d)\.(\d)", "$1?$2");
//replace an list of signs each with an blank:
//replacelist(string, searchlist, [replacelist], [separator], [matchcase])
$base = replacelist($base, "[]();!_-.{}", " ");
//Replace placeholders back to dots:
$base = replace($base, "?", ".");
text $base;
//Output: XYplorer Portable File Manager v9.90.001
livelike wrote:
2. as a final step of the code, rename all the selected files using the #126; command (Aaa Aaa.ext)
for this, not sure where to add the #126; command, to be used as the final step of the script.
I think that command will works on selected files in the file list
view, for re-casing an
string by
an script try command
recase()
Code: Select all
//title: to title case (first letter of each word to upper case, other letters to lower case)
$base = recase( $base , "Title");
//*** end specific
//Output:
Xyplorer Portable File Manager
V9.90.001
HTH?
--------------
Just out of interest, i did an few tests to build the menu commands to script commands:
My test file is:
XYplorer test File UPPER lower.txt
To change the case to:
XYplorer Test File UPPER Lower.Txt
use menu:
A* A*.* = Title-mode soft (preserve upper-case letters)
or in scripts:
#138;
And for strings in script use:
Code: Select all
$name = report("{basename}?{ext}",1);
$base = gettoken( $name, 1, "?");
$exte = gettoken( $name, 2, "?");
$base = recase( $base, "camel" );
text "$base.$exte";
To change the case to:
Xyplorer Test File Upper Lower.txt
use menu:
Aaa Aa.* = Title-mode strict (all words to title-case)
or in scripts:
#126;
And for strings in script use:
Code: Select all
$name = report("{basename}?{ext}",1);
$base = gettoken( $name, 1, "?");
$exte = gettoken( $name, 2, "?");
$base = recase( $base, "title" );
text "$base.$exte";
To change the case to:
xyplorer test file upper lower.txt
use menu:
aaa aa.aaa = Lower (All to lower-case)
or in scripts:
#127;
And for strings in script use:
Code: Select all
$name = recase( "<curname>", "lower");
Text $name;
To change the case to:
XYPLORER TEST FILE UPPER LOWER.TXT
use menu:
AAA AA.AAA = Upper
or in scripts:
#128;
And for strings in script use:
Code: Select all
$name = recase( "<curname>", "upper");
Text $name;
To change the case to:
XYplorer Test File UPPER Lower.txt
use menu:
*.aaa = extension to lower
or in scripts:
#136;
And for strings in script use:
Code: Select all
$name = report("{basename}?{ext}",1);
$base = gettoken( $name, 1, "?");
$exte = gettoken( $name, 2, "?");
$exte = recase( $exte, "lower" );
text "$base.$exte";
To change the case to:
XYplorer Test File UPPER Lower.TXT
use menu:
*.AAA = extension to upper
or in scripts:
#137;
And for strings in script use:
Code: Select all
$name = report("{basename}?{ext}",1);
$base = gettoken( $name, 1, "?");
$exte = gettoken( $name, 2, "?");
$exte = recase( $exte, "upper" );
text "$base.$exte";