(*
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;
|