You are not logged in.
Pages: 1
Hi everyone,
I have searched to see if my question has been answered, but no luck. What I would like to do is rename files and keep only the first letter of each word. Example:
"middle arc inside stiffener plate - flat pattern.dxf" would become "maisp-fp.dxf". I assume this can be done with a script, (?!?) but I have no idea how to do it. The spaces being removed isn't so important. That much I can manage on my own!
Thank you for any help you can give me!
By the way...what a great program! I can't begin to add up all the time it has saved me! Thanks den4b!!!!!!
Offline
Hi schmidty, welcome!
FROM:
"middle arc inside stiffener plate - flat pattern.dxf"
TO:
"maisp-fp.dxf".
DO:
Use an PascalScript (Wiki: HowTo use an PascalScript)
//get the first letter of all words and remove the rest, remove spaces too
//stefan
var
Words : TStringsArray;
FirstChars : WideString;
i : Integer;
begin
//init, emtpy the var
FirstChars:='';
//split the FileName into words at spaces
Words:=WideSplitString(WideExtractBaseName(FileName), ' ');
//for each word in words do: get first char
for i:=0 to Length(Words) - 1 do
FirstChars := FirstChars + WideCopy(Words[i], 1, 1);
//Compose the new FileName
FileName := FirstChars + WideExtractFileExt(FileName);
end.
Always test with copies of your files first.
HTH?
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
Stefan,
Ich danke Ihnen sehr viel! That script worked great!
I will read the "how-to" Wiki page you linked me to as well. Since I know exactly what your script does, I can use that as a learning tool to help me learn Pascal.
Thanks again!
Offline
There is an alternative way for doing this, using RegEx rule:
1) RegEx: Replace expression "(\w)\w*" with "$1" (skip extension)
2) Replace: Replace all " " with "" (skip extension)
This will also convert "middle arc inside stiffener plate - flat pattern.dxf" into "maisp-fp.dxf".
Script is of course a lot more flexible and highly customizable!
Offline
Pages: 1