Andrew
Code: Select all
{
Author: A Certain
Version: 1.0
Description:
This script will copy any ratings from the master version to all sub versions.
}
var
i: Integer;
AMain: TCatalogItem;
ACatItem: TCatalogItem;
AItem: TImageItem;
begin
if not Ask ('Are you sure you want to copy the master versions rating to all sub-versions of the selected images?' + CrLf2 + 'Beware; This is permanent and is not undoable!!') then
exit;
Progress.Cancel := False;
Progress.Max := Selected.Count;
Progress.Pos := 0;
Progress.Show;
AMain := TCatalogItem.Create(nil);
ACatItem := TCatalogItem.Create(nil);
try
for i := 0 to Selected.Count - 1 do
begin
Progress.Pos := i + 1;
Progress.ProgressText := Selected.Items[i].FileNameOnly;
AItem := Selected.Items[i];
if not AItem._isVersion then
continue;
else
begin
if Catalog.FindImageCombined (Selected.Items[i], AMain, True, phtNone) then
if AMain.Rating > 0 then
if Catalog.FindImageCombined (Selected.Items[i], ACatItem, False, phtNone) then
begin
ACatItem.Rating := AMain.Rating;
Catalog.StoreItemToDatabase (ACatItem, False);
end;
end;
if Progress.Cancel then
break;
end;
finally
AMain.Free;
ACatItem.Free;
end;
Progress.Hide;
if Progress.Cancel then
Say ('Cancelled')
end;