Resource

Resource Basics

Resource Name HEIC with MOV pairs
Resource Version 1.02
Category Search Scripts
Downloads 702
Release Date 10/25/2023 11:08:54 AM
 

Resource Details

Description This script will return:
All HEIC and MOV image pairs that share the same file name
Installation Instructions version 1.01; fix when Version sets exist with HEIC and MOV files
Usage Instructions 1. In Photo Supreme, click the dropdown in the Tab Bar above the thumbs
2. Select From Repository and then this script
Changes in this version 1.02; The results can now be filtered and a title is displayed in the result tab
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

const
  cGUID = 'CFD714556B73460ABDAC8F3B582BCAFC';

  procedure OpenNewTabForGroup(AGroup: TCatalogPropGroup);
  var
    AElem: TidElement;
  begin
    // delete results from a former run
    PublicCatalog.RemoveItemsFromTempList(AGroup.IncludeItems);

    // do search
    AElem := TidElement.Create(nil);
    try
      AElem.Prop['OpenNewTab'] := True;
      AElem.Data := AGroup;
      PublicBroadcast(nil, 'ShowGroupResults', AElem);
    finally
      AElem.Free;
    end;
  end;

  function MainFilter: WideString;
  begin
    result := 'select GUID ' +
              'from   idCatalogItem i ' +
              'where  i.idFileType = ''HEIC'' ' +
              'and    (' + 
              '       exists (' + 
              '                select  1 ' + 
              '                from    idcatalogItem i2 ' +
              '                where   i2.PathGUID = i.PathGUID ' +
              '                and     upper(i2.FileName) = upper(replace(i.FileName, ''.HEIC'', ''.MOV'')) ' + ' ' +
              '              )  ' +
              '       or exists (' + 
              '                   select  1 ' + 
              '                   from    idImageVersion i2 ' +
              '                   where   i2.PathGUID = i.PathGUID ' +
              '                   and     upper(i2.FileName) = upper(replace(i.FileName, ''.HEIC'', ''.MOV'')) ' + ' ' +
              '                 )  ' +
              '       ) ' +
              'union all ' + 
              'select GUID ' +
              'from   idCatalogItem i ' +
              'where  i.idFileType = ''MOV'' ' +
              'and    ( ' +
              '       exists (' + 
              '                select  1 ' + 
              '                from    idcatalogItem i2 ' +
              '                where   i2.PathGUID = i.PathGUID ' +
              '                and     upper(i2.FileName) = upper(replace(i.FileName, ''.MOV'', ''.HEIC'')) ' + ' ' +
              '              )  ' +
              '       or exists (' + 
              '                   select  1 ' + 
              '                   from    idImageVersion i2 ' +
              '                   where   i2.PathGUID = i.PathGUID ' +
              '                   and     upper(i2.FileName) = upper(replace(i.FileName, ''.MOV'', ''.HEIC'')) ' + ' ' +
              '                 )  ' +
              '       ) ' +
              'union all ' +
              'select GUID ' +
              'from   idImageVersion i ' +
              'where  i.idFileType = ''HEIC'' ' +
              'and    ( ' +
              '       exists (' + 
              '                select  1 ' + 
              '                from    idcatalogItem i2 ' +
              '                where   i2.PathGUID = i.PathGUID ' +
              '                and     upper(i2.FileName) = upper(replace(i.FileName, ''.HEIC'', ''.MOV'')) ' + ' ' +
              '              )  ' +
              '       or exists (' + 
              '                   select  1 ' + 
              '                   from    idImageVersion i2 ' +
              '                   where   i2.PathGUID = i.PathGUID ' +
              '                   and     upper(i2.FileName) = upper(replace(i.FileName, ''.HEIC'', ''.MOV'')) ' + ' ' +
              '                 )  ' +
              '       ) ' +
              'union all ' + 
              'select GUID ' +
              'from   idImageVersion i ' +
              'where  i.idFileType = ''MOV'' ' +
              'and    ( ' +
              '       exists (' + 
              '                select  1 ' + 
              '                from    idcatalogItem i2 ' +
              '                where   i2.PathGUID = i.PathGUID ' +
              '                and     upper(i2.FileName) = upper(replace(i.FileName, ''.MOV'', ''.HEIC'')) ' + ' ' +
              '              )  ' +
              '       or exists (' + 
              '                   select  1 ' + 
              '                   from    idImageVersion i2 ' +
              '                   where   i2.PathGUID = i.PathGUID ' +
              '                   and     upper(i2.FileName) = upper(replace(i.FileName, ''.MOV'', ''.HEIC'')) ' + ' ' +
              '                 )  ' +
              '       ) ' +
              '';
  end;

  procedure RunSearch;
  var
    ADs: TDBXOMClientDataSet;
    AGroup: TCatalogPropGroup;
  begin
    ADs := PublicCatalog.NewDataset;
    ADs.CommandText := 'select ' + PublicCatalog.FullColumnList('i.') + ' ' +
                       'from   v_catalogitem i ' +
                       'inner join (' + MainFilter + ') as f on f.GUID = i.GUID ' +
                       'UNION ALL ' +
                       'select ' + PublicCatalog.FullColumnList('i.') + ' ' +
                       'from   v_catalogitemversion i ' +
                       'inner join (' + MainFilter + ') as f on f.GUID = i.GUID ' +
                       'order by FileName ' +
                       '';
    ADs.LockType := ReadLockType;
    ADs.OpenSet;

    AGroup := TCatalogPropGroup.Create(nil);
    AGroup.GroupName := 'HEIC with MOV Pairs';
    AGroup.IncludeItems.GUID := cGUID;  // fix the GUID
    AGroup.IncludeItems.AddDataset(ADs, True);
    AGroup.IncludeItems.Disconnect;

    OpenNewTabForGroup(AGroup);

    PublicCatalog.FreeDataset(ADs);

    AGroup.Free;
  end;

begin
  RunSearch;
end;