Resource

Resource Basics

Resource Name Cascade Meta to Full Version Set for Photo Supreme
Resource Version 1.0.5
Category Version
Downloads 1638
Release Date 3/1/2019 8:19:58 PM
 

Resource Details

Description This script batch cascades metadata from several selected main versions to all their subversions.
Installation Instructions Download the script to a folder on you hard drive
Usage Instructions 1. Select one or more Version Sets for which you want to cascade metadata
2. Open Tools -> Scripter
3. Open this script
4. Run the script
Changes in this version Last Change: 2023-08-08; added InternalMetaCascadeForItem to allow more details to be cascaded
Change: 2023-08-07; fix for changed parameters for CascadeMetaForItem and better progress implementation
Change 1.0.3: 2019-03-01; made compatible for Photo Supreme
Change 1.0.2: 2014-02-21; made compatible for Photo Supreme
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

{
 Author: support@idimager.com
 Version: 1.0.5
 Last Change: 2023-08-08; added InternalMetaCascadeForItem to allow more details to be cascaded
      Change: 2023-08-07; fix for changed parameters for CascadeMetaForItem and better progress implementation
      Change 1.0.3: 2019-03-01; made compatible for Photo Supreme
      Change 1.0.2: 2014-02-21; made compatible for Photo Supreme

 Description:

 This version will cascade the meta data to the entire version stack. The script will always take the main version for every selected
 image and then cascade the main version's meta-data to every sub-version in the version stack. Beware that this overwrites the sub
 version's meta-data (Exif, IPTC and XMP) and replace it with the main version's data
 image and then cascade the main version's meta-data to every sub-version in the version stack. Beware that this overwrites the sub
 version's meta-data (Exif, IPTC and XMP) and replace it with the main version's data
}

function InternalCascadeMetaForItem(AItem: TCatalogItem): Boolean;
var
  AVersions: TCatalogItems;
  AMain: TCatalogItem;
  ATypes: TCatalogCascadeTypes;
begin
  result := False;
  AVersions := TCatalogItems.Create(TCatalogItem, '');
  AMain := TCatalogItem.Create(nil);
  try
    if not PublicCatalog.FindItemCombined2(AItem, AMain, True, vptNone) then
      exit;

    // make sure we have the latest info
    PublicCatalog.FindItemCombined2(AItem, AItem, False, vptNone);
    // enum the version stack
    PublicCatalog.EnumVersionsForItem(AMain, AVersions);

    // all but orientation and cataloglabels
    ATypes := [cctMeta, cctRatings, cctLabels, cctXMP, cctXMPTechnical, cctGEOCoordinates];
    PublicCatalog.CascadeToTargetsForItem(AItem, AVersions, ATypes, PublicOptions);
    result := True;
  finally
    AVersions.Free;
    AMain.Free;
  end;
end;

var
  i: Integer;
  AMain: TCatalogItem;
  AProgress: TxomProgress;
begin
  if not Ask ('Are you sure you want to cascade the meta data to the entire version stack based on the meta data for the main version of the selected images?' + CrLf2W + 'Beware; This is permanent and is not undoable!!' + CrLf2W) then
    exit;

  AProgress := TxomProgress.Create(nil);
  AProgress.Max := Selected.Count;
  AProgress.Pos := 0;

  AProgress.Show;

  for i := 0 to Selected.Count - 1 do
  begin
    AProgress.Pos := i + 1;
    AProgress.ProgressText := Selected.Items[i].FileNameOnly;

    AMain := TCatalogItem.Create(nil);
    try
      if PublicCatalog.FindImageCombined(Selected.Items[i], AMain, True, phtNone) then    // make sure we find the main version for the selected image
        InternalCascadeMetaForItem(AMain);                       // cascade the main version's meta data to all sub versions
    finally
      AMain.Free;
    end;

    if AProgress.Cancel then
      break;
  end;

  AProgress.Hide;

  if AProgress.Cancel then
    Say ('Cancelled')

  AProgress.Free;
end;