Resource

Resource Basics

Resource Name Rename & Download by Prefix Import Script
Resource Version 0.21
Category Download Pre
Downloads 902
Release Date 7/14/2016 2:57:10 PM
 

Resource Details

Description The Download by Rename & Download by Prefix Import Scripts will rename JPG+RAW pairs constructing a filename for Photo Supreme's Importer consisting of:

• A user entered prefix
• A sequential, zero-padded, 4-digit integer value
• The original file extension

To give you an example:

You have a series of file pairs from your camera called:
_DSC1234.jpg
_DSC1234.nef.
_DSC1235.jpg
_DSC1235.nef.
_DSC1236.jpg
_DSC1236.nef.
_DSC1237.jpg
_DSC1237.nef.
etc.

Now, you would like to import these files with a custom defined prefix (for example your name or a letter code like ZX and an underscore) plus a four-digit sequence number, e.g.:

ZX_0001.jpg
ZX_0001.nef
ZX_0002.jpg
ZX_0002.nef
ZX_0003.jpg
ZX_0003.nef
ZX_0004.jpg
ZX_0004.nef
etc.

Next time, when downloading the next batch of file pairs you'd like the last number to be remembered, e.g., continuing with 5, 6, 7, etc.:
Installation Instructions See the attached PDF.
Usage Instructions See the attached PDF.
Changes in this version The script was originally written for IDimager v. 5 by Jeff Godfrey on 16-Apr-2007, and subsequently converted to be compatible with Photo Supreme 3 by Hertwig van Zwietering on 23-Jun-2016. Thank you!

version 0.21; made compatible with high resolution screens
Special Requirements
 

Author Information

Author Name Frank Bungartz
 

Available Attachments

Attachment #1 Import by Prefix Insstallation Instructions.pdf
 

Script

// fix for high res screens
var
  FPrefixEdit  : TvxTextBox;
  FSequenceEdit: TvxTextBox;

  procedure btnGetValClick(Sender: TObject);
  var
    ALastVal:   Integer;
    APrefix:    WideString;
  begin
    APrefix := Trim(FPrefixEdit.Text);
    if (APrefix = '') then
       Say('Error - Please enter a file prefix.');
    else
    begin
      ALastVal := ReadFromRegistry ('dlByPrefixLastVals', APrefix, 0);
      Inc(ALastVal);
      FSequenceEdit.Text := IntToStr(ALastVal);
    end;
  end;

  procedure PrefixEditChange(Sender: TObject);
  begin
    if FPrefixEdit.Text <> '' then
      btnGetValClick(Sender)
    else
      FSequenceEdit.Text := '';
  end;

  function BuildForm: TvxSceneForm;
  var
    ALabel: TvxLabel;
  begin
    result := TvxSceneForm.Create(nil);
    result.Caption := 'Download by Prefix - v0.21';
    result.Width := 360 * result.DPIFactor;
    result.Height := 150  * result.DPIFactor;

    ALabel := TvxLabel.Create(result);
    ALabel.TextAlign := vgTextAlignNear;
    ALabel.Width := 200;
    ALabel.Position.Point := vgPoint(20, 24);
    ALabel.Text := '1. Enter prefix for downloaded files';
    result.Root.AddObject(ALabel);

    FPrefixEdit := TvxTextBox.Create(result);
    FPrefixEdit.Width := 120;
    FPrefixEdit.Position.Point := vgPoint(210, 20);
    FPrefixEdit.Text := ReadFromRegistry ('dlByPrefixCurrent', 'prefix', '');
    FPrefixEdit.OnTyping := 'PrefixEditChange';

    result.Root.AddObject(FPrefixEdit);

    ALabel := TvxLabel.Create(result);
    ALabel.TextAlign := vgTextAlignNear;
    ALabel.Width := 200;
    ALabel.Position.Point := vgPoint(20, 64);
    ALabel.Text := '2. Edit sequence number if needed';
    result.Root.AddObject(ALabel);

    FSequenceEdit := TvxTextBox.Create(result);
    FSequenceEdit.Width := 120;
    FSequenceEdit.Position.Point := vgPoint(210, 60);
    result.Root.AddObject(FSequenceEdit);

    result.PrepareModal([mbOk, mbCancel]);

    PrefixEditChange(nil);
  end;

  procedure StartAction;
  var
    ALastVal: Integer;
    APrefix:  WideString;
    AValStr:  WideString;
    AValue:   Integer;
  begin
    APrefix := Trim(FPrefixEdit.Text);
    if (APrefix = '') then
    begin
      Say('Error - Please enter a file prefix.');
      Exit;
    end;

    AValStr := Trim(FSequenceEdit.Text);
    if (AValStr = '') then
    begin
      Say('Error - please enter a starting value');
      Exit;
    end;

    AValue := StrToInt(AValStr) - 1;

    // update the current* registry keys, so the renaming script can find them
    WriteToRegistry ('dlByPrefixLastVals', APrefix, AValue);
    WriteToRegistry ('dlByPrefixCurrent', 'prefix', APrefix);
    WriteToRegistry ('dlByPrefixCurrent', 'value', AValue);
    WriteToRegistry ('dlByPrefixCurrent', 'filename', '');
  end;

var
  AForm: TvxSceneForm;
begin
  AForm := BuildForm;
  AForm.ShowModal;

  if AForm.ModalResult = mrOk then
    StartAction;

  AForm.Free;
end;