Jump to content

Fo4Edit: need a script to rename multiple items


Recommended Posts

  • 3 months later...

Use this:

{
  This script will prepend or append supplied value to the Name field
  of every selected record.
}
unit UserScript;

var
  DoPrepend: boolean;
  s: string;
 
function Initialize: integer;
var
  i: integer;
begin
  Result := 0;
  // ask for prefix or suffix mode
  i := MessageDlg('Prepend [YES] or append [NO] to Item Name?', mtConfirmation, [mbYes, mbNo, mbCancel], 0);
  if i = mrYes then DoPrepend := true else
    if i = mrNo then DoPrepend := false else begin
      Result := 1;
      Exit;
    end;
  // ask for string
  if not InputQuery('Enter', 'Prefix/suffix', s) then begin
    Result := 2;
    Exit;
  end;
  // empty string - do nothing
  if s = '' then
    Result := 3;
end;

function Process(e: IInterface): integer;
var
  elEditorID: IInterface;
begin
  Result := 0;
  //AddMessage('Processing: ' + Name(e));
  elEditorID := ElementByName(e, 'FULL - Name');
  if Assigned(elEditorID) then begin
    if DoPrepend then
      SetEditValue(elEditorID, s + GetEditValue(elEditorID))
    else
      SetEditValue(elEditorID, GetEditValue(elEditorID) + s);
  end;
end;

end.
Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...