Through working with online scripts in the repository (and marginal knowledge of pascal) I've created the script below. It currently is coded to recognise .rw2 files but can be adapted easily enough.
I've been fumbling around and it seems to work according my intention. I would like to be able to sort on photo date - that may come later unless someone can guide me on this.
There were a few odd things I couldn't get past (so created a new instance of ADs to delete idTempList at end of script)
I'm happy if anyone wants to tidy this up.
kind regards
anyhow:
Code: Select all
var
i: Integer;
RawFile: WideString;
RawExt: WideString;
ADs: TDBXOMClientDataSet;
AGUID: String;
AItems: TCatalogItems;
begin
if Selected.Count = 0 then
begin
Say('No image selected');
exit;
end;
AGUID :='wphFB798C977A734F4FACDF1FF204676A87';
ADs := Catalog.NewDataSet;
ADs.CommandText := 'delete from idTempList where ClassGUID=''' + AGUID + '''';
ADs.Run;
RawExt := '.rw2';
for i := 0 to Selected.Count - 1 do
begin
If CompareText(ExtractFileExt(Selected.Items.FileName),RawExt)<>0 Then
Begin
RawFile := ChangeFileExt(Selected.Items.FileName,RawExt);
If WideFileExists(RawFile) Then
Begin
ADs.CommandText := 'insert into idTempList (ClassGUID, GUID) ' +
'select ''' + AGUID + ''', idCatalogItem.GUID ' +
'from idCatalogItem inner join idFilePath ' +
'on idCatalogItem.PathGUID = idFilePath.GUID ' +
'where (idCatalogItem.FileName = ''' + ExtractFileName(RawFile) + ''') ' +
' and (idFilePath.FilePath = ''' + ExtractFilePath(RawFile) + ''') ' +
'';
//CopyTextToClipboard(ADs.CommandText);
ADs.Run;
end;
end;
end;
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 ' +
'order by FullFileName ' +
'';
//CopyTextToClipboard(ADs.CommandText);
ADs.OpenSet;
AItems := TCatalogItems.Create(TCatalogItem, '');
AItems.Name := RawExt + ' from sel.';
AItems.AddDataSet (ADs, True);
PublicBroadCast(nil, 'OpenNewTab', nil);
PublicBroadcastObject(nil, 'ShowImageResults', AItems, nil, nil);
AItems.Free;
ADs.CloseSet;
Catalog.FreeDataSet (ADs);
ADs := Catalog.NewDataSet;
ADs.CommandText := 'delete from idTempList where ClassGUID=''' + AGUID + '''';
ADs.Run;
Catalog.FreeDataSet (ADs);
Say ('Done. Found ' + RawExt + ' files are placed in a new Tab');
end;