Resource

Resource Basics

Resource Name Folder Name to Catalog Label
Resource Version 2.1
Category Catalog
Downloads 1093
Release Date 8/14/2014 10:39:10 AM
 

Resource Details

Description This script will create a catalog label hierarchy for the path hierarchy for every selected thumbnail.

e.g. F:\My Pictures\2004\Trip to Spain\test.jpg
wiill get a hierarchy label structure
My Pictures
|
|-- 2004
|
|---- Trip to Spain

The lowest level leaf (Trip to Spain in this sample) will be assigned to the thumbnail.
Installation Instructions Download the script to a folder on your hard drive
Usage Instructions 1. Select the thumbnails that you want to process
2. Select Tools -> Scripter
3. Load the downloaded script
4. Run the script with the run button
Changes in this version 2.0; Made compatible with Photo Supreme
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

{
  Update 2.0; 2014-08-14; Made compatible with Photo Supreme
  Update 2.1; 2017-11-22; Added confirmation question
}
procedure HandleImage (AImage: TImageItem; AMain: TCatalogItem);
var
  APath: TTntStringList;
  APathName: WideString;
  AProp: TCatalogItemProp;
  APathHierarchy, ASeparator: WideString;
begin
  APath := TTntStringList.Create;
  APathName := WideExcludeTrailingBackslash(WideExtractFilePath (AImage.FileName));
  if LeftStr(APathName, 2) = '\\' then
    APathName := 'x\' + MidStr(APathName, 3, Length(APathName));

  if IsWindows then
    ASeparator := '\'
  else
    ASeparator := '/';
  Tokenize (APathName, ASeparator, APath);

  AProp := TCatalogItemProp.Create(nil);
  APathHierarchy := '';
  // skip the first item in the list; it is the drive/volume
  for i := 1 to APath.Count - 1 do
    APathHierarchy := APathHierarchy + iif(APathHierarchy = '', '', '::') + APath.Strings[i];

  if Catalog.FindPropByPathName (APathHierarchy, AProp, '::', True) then
    Catalog.AddPropToItem (AMain, AProp, False, False);
  AProp.Free;

  APath.Free;
end;

var
  i: Integer;
  ACatItem: TCatalogItem;
begin
  if Selected.Count = 0 then
  begin
    Say('No images selected');
    exit;
  end;

  if not Ask('Are you sure you want to create Catalog Labels for the ' + IntToStr(Selected.Count) + ' selected images?') then
    exit;

  Progress.Cancel := False;
  Progress.Max := Selected.Count;
  Progress.Pos := 0;
  Progress.Show;

  for i:= 0 to Selected.Count - 1 do
  begin
    Progress.Pos := i + 1;

    ACatItem := TCatalogItem.Create(nil);
    // find the main item in the catalog; this is the one that gets the assigned label
    if Catalog.FindImageCombined (Selected.Items[i], ACatItem, True, vptNone) then
      HandleImage (Selected.Items[i], ACatItem);

    ACatItem.Free;

    if Progress.Cancel then
      break;
  end;

  Progress.Hide;
end;