Page 1 of 1

Find duplicates

Posted: 2003-01-05 21:44:27
by Ork
Here is a script that find all duplicates.
It writes the results in c:\duplicates.txt along with the numbers of each occurence of the duplicate title.
To change the file, simply change the value at the end of the code (line 98).

Code: Select all

//SCRIPTING
//Find duplicates in a list

(***************************************************
 *  Script to find duplicates in the list of       *
 *  selected movies.                               *
 *  It doesn't see empty fields.                   *
 *                                                 *
 * (c) 2003 Louis Francisco ork@everydayangels.net *
 *                                                 *
 *  For use with Ant Movie Catalog 3.4.1           *
 *  www.ant.be.tf/moviecatalog ··· www.buypin.com  *
 *                                                 *
 *  The source code of the script can be used in   *
 *  another program only if full credits to        *
 *  script author and a link to Ant Movie Catalog  *
 *  website are given in the About box or in       *
 *  the documentation of the program               *
 ***************************************************)
program FindDuplicates;
const
  NMAX=260; //Set to the last number in the list
var
  Titles:TStringList;
  Numbers:TStringList;
  Duplicates:TStringList;
  CurrentTitle:string;
  CurrentNumber:string;

function FindTitle(title:string;list:TStringList):integer;
var
  i:integer;
begin
  result:=-1;
  for i:=0 to list.Count-1 do
  begin
    if list.GetString(i)=title then
    begin
      result:=i;
      break;
    end;
  end;
end;

procedure FindDuplicates();
var
  numTitle,numDup:integer;
begin
  numTitle:=FindTitle(CurrentTitle,Titles);
  if numTitle<>-1 then
  begin
    numDup:=FindTitle(CurrentTitle,Duplicates);
    if numDup=-1 then
    begin
      Duplicates.Text:=Duplicates.Text+
        CurrentTitle+' ('+Numbers.GetString(numTitle)
        +', '+CurrentNumber;
    end
    else
    begin
      Duplicates.SetString(numDup,
        Duplicates.GetString(numDup)+', '+CurrentNumber);
    end;
  end;
  Titles.Text:=Titles.Text+CurrentTitle;
  Numbers.Text:=Numbers.Text+CurrentNumber;
end;

procedure SaveToFile(fileName:string);
var
  i:integer;
begin
  for i:=0 to Duplicates.Count-1 do
  begin
    Duplicates.SetString(i,Duplicates.GetString(i)+')');
  end;
  Duplicates.SaveToFile(fileName);
end;

begin
  if CheckVersion(3,4,1) then
  begin
    if Titles=nil then
    begin
      Titles:=TStringList.Create;
      Numbers:=TStringList.Create;
      Duplicates:=TStringList.Create;
    end;

    CurrentTitle:=GetField(fieldOriginalTitle);
    CurrentNumber:=GetField(fieldNumber);
    // If title is empty, it generates bugs while looking to the
    // number of a duplicate movie.
    if CurrentTitle<>'' then FindDuplicates;

    if StrToInt(CurrentNumber,0)=NMAX then
    begin
      SaveToFile('c:\duplicates.txt');
      Titles.Free;
      Numbers.Free;
      Duplicates.Free;
    end;
  end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
end.

Posted: 2003-01-05 22:01:38
by antp
Thanks ;)

Posted: 2005-08-16 14:24:43
by furetto
is it possible to have a newer version of this script, so it can be used with version 3.5 ?

I tried to use it with the new version of AMC, but it doesn't work :cry:

Posted: 2014-12-09 09:50:34
by toff
9 years after, I'm seconding that :)

Posted: 2014-12-09 10:27:20
by antp
The one included in AMC does not work?
(accessible via Tools->Scripting)

Posted: 2014-12-19 15:28:16
by kveda
I have been looking in scripting and didn´t find the option.
How can i find duplicates.
Regards

Posted: 2014-12-20 21:43:49
by antp
In Tools->Scripting you do not have "Find Duplicates" that appears in the list?
It is included with AMC's standard install but if you don't have the script you can find it on http://update.antp.be/amc/scripts/archive/