Resource

Resource Basics

Resource Name Export to sidecar XMP file
Resource Version 1.0
Category Metadata
Downloads 2273
Release Date 10/29/2020 2:10:35 PM
 

Resource Details

Description This script will export existing XMP from the catalog to a sidecar file
Installation Instructions Download the script to a folder
Usage Instructions 1. Select the images to export for
2. Start the Scripter
3. Load the downloaded script
4. Run the script
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script


  procedure ExportXMPSidecarFor(AImage: TImageItem);
  var
    AXmp: TXMP;
    ASidecar: WideString;
  begin
    ASidecar := WideChangeFileExt(AImage.FileName, '.xmp');

    AXmp := TXMP.Create(False);
    try
      PublicCatalog.LoadXMPForImage(AImage, AXmp, PublicOptions.CachedXMP);
      AXmp.SaveToFile(ASidecar, AImage.ExifFileName);
    finally
      AXmp.Free;
    end;
  end;

var
  i: Integer;
  AImage: TImageItem;
  ASidecar: WideString;
  APro: TxomProgress;
begin
  if Selected.Count = 0 then
  begin
    Say2('No images selected.', 'Select one or more thumbnails and try again.');
    exit;
  end;

  APro := TxomProgress.Create(nil);
  APro.Caption := 'Export metadata to sidecar XMP file';
  APro.Max := Selected.Count;
  for i := 0 to Selected.Count - 1 do
  begin
    AImage := Selected.Items[i];

    APro.Pos := i + i;
    APro.ProgressText := AImage.FileNameOnly;
    if APro.Cancel then
      break;
    ExportXMPSidecarFor(AImage);
  end;
  APro.Free;
end;