You are not logged in.
Pages: 1
How can I insert a - between names in a file?
From;
WRS0IC301705-BeltScrewWeighingSystem.doc
To:
WRS0IC301705-Belt-Screw-Weighing-System.doc
Offline
Hi Dave,
welcome to the forum
I would do that with regular expressions.
RegEx basics:
Search for any single lower case char [a-z]
followed by
Search for any single upper case char [A-Z]
Put () around this search to could refer to the search result later, so use:
Search for any single lower case char ([a-z])
Search for any single upper case char ([A-Z])
Later you can use $n to use the search result in your replacement. 'n' represents here the number of the n-th ()-group.
Use this with ReNamer:
So add an new RULE > RegEx
Expression: ([a-z])([A-Z])
Replace: $1-$2
The lower and upper cased chars in the RegEx should be enough, but you have to check "[x] case-sensitive" too.
See an pic abou this:
I used here Replace: $1 - $2
Last edited by Stefan (2008-02-16 11:34)
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
To Denis.
this similar script
http://www.den4b.com/forum/viewtopic.php?id=14
gives me an Type mismatch
---------------------------
Error
---------------------------
Preview process has been terminated due to a critical error:
Pascal Script Compile:
[Line 21] Error: Type mismatch ==> if IsLetter(FileName[i]) then
---------------------------
OK
---------------------------
(BTW: "Go to line" in Script-Rule works fine)
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
I posted an updated script and the explanation in that topic:
Insert blank space between lowercase and uppercase
So, DaveP, you can use the code from that topic, but simply change the separator, like this:
const
Separator = '-';
var
I: Integer;
begin
for I:=WideLength(FileName) downto 2 do
if IsWideCharAlpha(FileName[i]) then
if IsWideCharUpper(FileName[i]) and
IsWideCharLower(FileName[I-1])
then WideInsert(Separator, FileName, I);
end.
It will work slighly faster than the RegEx rule, but RegEx rule might be more future proof.
Offline
Fantastic!
Stefan's RegEx worked great.
Thanks a bunch!!!!!!!!!!:)
Offline
Pages: 1