Resource

Resource Basics

Resource Name Find Duplicates in Photo Supreme
Resource Version 1.11
Category Catalog
Downloads 989
Release Date 2/18/2014 11:04:51 AM
 

Resource Details

Description This script will try to collect duplicate files in your catalog.
NOTE: Duplicate files are determined on the file size and so it is possible that you get some false positives when you have files with the exact same file size in the Catalog.
Installation Instructions Download the file to your hard drive
Usage Instructions 1. Open Tools -> Scripter
2. Load this script
3. Run the script
4. close the Scripter

The results (if any) will be in the Collection Viewer
Changes in this version 1.11; Fix for AddDataSet
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

(*
  Script: Find Duplicates in Photo Supreme
  Author: IDimager
  Version: 1.1
*)

var
  ADs: TDBXOMClientDataSet;
  AGUID: String;
  AItems: TCatalogItems;
begin
  AGUID := 'dup924E67D39D9E43AE8D3246597254A483';

  ADs := Catalog.NewDataSet;

  ADs.CommandText := 'delete from idTempList where ClassGUID=''' + AGUID + '''';
  ADs.Run;

  ADs.CommandText := 'insert into idTempList (ClassGUID, GUID) ' +
                       'select ''' + AGUID + ''', GUID ' +
                       'from idCatalogItem ' +
                       'where FileSize in ' +
                       '( ' +
                       '  select FileSize ' +
                       '  from ' +
                       '    ( ' +
                       '      select GUID, FileSize ' +
                       '      from v_CatalogItem ' +
                       '      union all ' +
                       '      select GUID, FileSize ' +
                       '      from v_ImageVersion ' +
                       '    ) as idTbl ' +
                       '  group by FileSize ' +
                       '  having Count(1) > 1 ' +
                       ') ' +
                       '';
  ADs.Run;

  ADs.CommandText := 'insert into idTempList (ClassGUID, GUID) ' +
                       'select ''' + AGUID + ''', GUID ' +
                       'from idImageVersion ' +
                       'where FileSize in ' +
                       '( ' +
                       '  select FileSize ' +
                       '  from ' +
                       '    ( ' +
                       '      select GUID, FileSize ' +
                       '      from v_CatalogItem ' +
                       '      union all ' +
                       '      select GUID, FileSize ' +
                       '      from v_ImageVersion ' +
                       '    ) as idTbl ' +
                       '  group by FileSize ' +
                       '  having Count(1) > 1 ' +
                       ') ' +
                       '';
  ADs.Run;

  ADs.CommandText := 'select ' + Catalog.FullColumnList('v.') + ' ' +
                     'from   v_CatalogItem v, idTempList t ' +
                     'where  t.ClassGUID = ''' + AGUID + ''' ' +
                     'and    v.GUID = t.GUID ' +
                     'union all ' +
                     'select ' + Catalog.FullColumnList('v.') + ' ' +
                     'from   v_CatalogItemVersion v, idTempList t ' +
                     'where  t.ClassGUID = ''' + AGUID + ''' ' +
                     'and    v.GUID = t.GUID ' +
                     '';
  ADs.OpenSet;
  //PublicBroadcast(nil, 'ResetActiveCollection', nil);
  //ActiveCollection.Items.AddDataSet(ADs);
  //PublicBroadcast(nil, 'RefreshActiveCollection', nil);
  AItems := TCatalogItems.Create(TCatalogItem, '');
  AItems.Name := 'Find Duplicates';
  AItems.AddDataSet (ADs, True);
  PublicBroadcastObject(nil, 'ShowImageResults', AItems, nil, nil);
  AItems.Free;
  ADs.CloseSet;

  ADs.CommandText := 'delete from idTempList where ClassGUID=''' + AGUID + '''';
  ADs.Run;

  Catalog.FreeDataSet (ADs);

  Say2 ('Done. Found duplicates are placed in a new Tab', 'You can close this window now and see the duplicates (if any)');
end;