now and then i receive from colleagues files and lists which contains names when it comes to files or words in text lists like the following: KenRobinson-DoSchoolsKillCreativity?
how do I convert that into "Ken Robinson - Do Schools Kill Creativity?" both on files and in source documents?
splitting words
Re: splitting words
That sounds like a job for regular expressions, which I can't help you with unfortunately; other forum members do know about it. By using those, XYplorer should be able to rename the files as you want them.Wanda wrote:now and then i receive from colleagues files and lists which contains names when it comes to files or words in text lists like the following: KenRobinson-DoSchoolsKillCreativity?
how do I convert that into "Ken Robinson - Do Schools Kill Creativity?" both on files and in source documents?
As for the content of files, it may be possible to script something in XYplorer, but a much more robust way would be to use a text editor like Notepad++ (freeware) which supports replacing with regular expressions; the same expression as used by XYplorer should be usable.
Hope this helps (somewhat...
Re: splitting words
Hi Wanda, here are some ideas for you:
Space between lower upper case chars regex
(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
------------------
@Don, wish:
writefile(filename, data, [on_exist], [mode])
on_exist
r: create new file/if existing: append suffix number "original_001.ext"
.
An RegEx could look like this:Wanda wrote: like the following: KenRobinson-DoSchoolsKillCreativity?
how do I convert that into "Ken Robinson - Do Schools Kill Creativity?"
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;
To rename file see rename() scripting command.both on files
To replace in file content an possible code could look like:and in source documents?
(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"
.
-
admin
- Site Admin
- Posts: 64915
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: splitting words
Good, done.Stefan wrote:@Don, wish:
writefile(filename, data, [on_exist], [mode])
on_exist
r: create new file/if existing: append suffix number "original_001.ext"
FAQ | XY News RSS | XY X
Re: splitting words
thank you too. i can now deal with that boring files properly. thank you.
Re: splitting words
Thank you so much I can now handle those tedious files correctly.
XYplorer Beta Club