You are not logged in.
Pages: 1
I have a file named: 1234 adirving adirving IV 09-20-2006
I want it to be remaned to: 1234 adirving IV 09-20-2006.
Is there a way to do this?
Offline
Use the code below in PascalScript. It will remove all the duplicated words, so the last thing for you to do will be to remove the extra spaces, using CleanUp rule - fix spaces option.
var
Words: TStringsArray;
BaseName, Extension: WideString;
I, A: Integer;
begin
Extension := WideExtractFileExt(FileName);
BaseName := WideExtractBaseName(FileName);
Words := WideSplitString(BaseName, ' ');
if WideArrayLength(Words) < 1 then Exit;
for I:=0 to WideArrayLength(Words)-2 do
for A:=I+1 to WideArrayLength(Words)-1 do
if WideSameText(Words[i], Words[A]) then
Words[A] := '';
BaseName := Words[0];
for I:=1 to WideArrayLength(Words)-1 do
BaseName := BaseName + ' ' + Words[i];
FileName := BaseName + Extension;
end.
Offline
I tried this script in version 5.70 of Renamer, and get the following error:
Preview process has been terminated due to a critical error:
Pascal Script Compile:
[Line 10] Error: Unknown identifier 'WideArrayLength'
Offline
Hi tom, welcome.
Sorry for the inconvenience.
See History.txt:
ReNamer 4.50
• Updated PascalScript source :
1) SetLength() and Length() functions work for both WideStrings and Arrays;
2) Widestring indexed character access is working, i.e. WideString[1];
Note: WideArrayLength() and WideArraySetLength() functions are removed!
So update the script to this by removing the 'WideArray' part:
var
Words: TStringsArray;
BaseName, Extension: WideString;
I, A: Integer;
begin
Extension := WideExtractFileExt(FileName);
BaseName := WideExtractBaseName(FileName);
Words := WideSplitString(BaseName, ' ');
if Length(Words) < 1 then Exit;
for I:=0 to Length(Words)-2 do
for A:=I+1 to Length(Words)-1 do
if WideSameText(Words[i], Words[A]) then
Words[A] := '';
BaseName := Words[0];
for I:=1 to Length(Words)-1 do
BaseName := BaseName + ' ' + Words[i];
FileName := BaseName + Extension;
end.
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
Pages: 1