Find duplicates

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
Ork
Posts: 44
Joined: 2003-01-03 23:52:51
Location: Castres, France

Find duplicates

Post 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.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks ;)
furetto
Posts: 6
Joined: 2005-08-16 14:22:42

Post 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:
toff
Posts: 10
Joined: 2011-04-02 09:46:15

Post by toff »

9 years after, I'm seconding that :)
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

The one included in AMC does not work?
(accessible via Tools->Scripting)
kveda
Posts: 3
Joined: 2014-11-17 18:31:38

Post by kveda »

I have been looking in scripting and didn´t find the option.
How can i find duplicates.
Regards
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post 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/
Post Reply