Hi Wanda, here are some ideas for you:
Wanda wrote:
like the following: KenRobinson-DoSchoolsKillCreativity?
how do I convert that into "Ken Robinson - Do Schools Kill Creativity?"
An RegEx could look like this:
Space between lower upper case chars regex
Code: Select all
$IN = "KenRobinson-DoSchoolsKillCreativity";
// TO Ken Robinson - Do Schools Kill Creativity
//-------------------------------------------------------------------
$OUT=$IN;
while($Infinity < 99)
{
$OUT = regexreplace( $OUT, "(.+?[a-z])([A-Z].+)", "$1 $2", 1);
//if there is nothing modified, then regexreplace() returns just the input
//so if current the same as the last all is done and we can break:
if ($last==$OUT){break;}
$last=$OUT;
$Infinity++;
}
//-------------------------------------------------------------------
$OUT = replace($OUT, "-", " - ");
//-------------------------------------------------------------------
msg $OUT;
both on files
To rename file see rename() scripting command.
and in source documents?
To replace in file content an possible code could look like:
(but perhaps you already know the line containing the string then you didn't need an loop)
NOTE be sure to not replace binary or W0rd D0cs, and always test with copies of real files!!!
Modify file content lines search replace.xys
Code: Select all
// === User settings===
$file = "c:\temp\xyvbs.vbs";
$FIND = "Wshell";
$REPL = "WS";
// === code ===
//read whole file into var:
$content = readfile($file);
//get amount of parts of file, delimitered by an newline, a.k.a Lines count:
$lines = gettoken($content, "count", "<crlf>");
$OUT="";
$i=1;
//loop over all lines
while($i <= $lines)
{
$line = gettoken($content, $i, "<crlf>");
if ($line==""){break;}
if ( strpos($line, $FIND) > 0 )
{
$OUT = $OUT . replace($line, $FIND, $REPL);
}
else
{
$OUT = $OUT . $line;
}
if ($i < $lines){$OUT = $OUT . "<crlf>";}
$i++;
}
//return output
writefile( $file . "_modified.vbs", $OUT );
msg "DONE";
------------------
@Don, wish:
writefile(filename, data, [on_exist], [mode])
on_exist
r: create new file/if existing: append suffix number "original_001.ext"
.