set current movie in script

If you need help on how to use the program
Post Reply
J
Posts: 224
Joined: 2008-02-17 17:09:26

set current movie in script

Post by J »

hi,

is there a way to set the current movie with/from a variable in a script?

I want to script-import a lot of pictures from disk as an extra to the corresponding movies in the catalog. The picture name format is "movienumber_picnumber.jpg" (e.g. 635_1.jpg).

how can I add this example picture as an extra to movie with number 635?
Func ImportExtraPicture() imports to current movie, which is always first movie.

What I need is either set the current movie to "movienumber" or a function to import to a specific movienumber.

thanks
J.
J
Posts: 224
Joined: 2008-02-17 17:09:26

[solved]

Post by J »

OK,

made two solutions just in case someone might have usage for this too.
All pictures are in one directory with naming convention text_movienumber_picturenumber.jpg (e.g. Filme_635_1.jpg)

1: New function "SetActualMovie(movienumber);" to set current movie needed:

Code: Select all

program picture_helper;

uses
  StringUtils1;
  
var
  DirList: TStringList;
  counter, index: integer;
  picture, movienumber: string;
  
begin
  DirList := TStringList.Create;
  DirList.Text := ListDirectory('D:\MPtest\', '*.*');

  for counter := 2 to DirList.Count - 1 do
    begin
	  picture := TextBefore(DirList.GetString(counter), #09, '');
	  movienumber := TextBetween(picture, '_', '_');
	  SetActualMovie(movienumber);  // needed function !
	  index := AddExtra;
	  ImportExtraPicture(index, 'd:\mptest\' + picture);
	  SetExtraField(index, eCategory, 'Stills');
	end;

  DirList.Free;
end.
2: Nothing needed, just works

Code: Select all

program picture_helper_2;

uses
  StringUtils1;
  
var
  DirList: TStringListEx;
  index: integer;
  picture, movienumber: string;
  
begin
  if GetIteration = 0 then 
    begin
		DirList := TStringListEx.Create;
		DirList.Text := ListDirectory('D:\MP\', '*.*');
		DirList.Delete(0);
		DirList.Delete(0);
		DirList.NaturalSort;
	end;
  
  movienumber := TextBetween(DirList.GetString(0), '_', '_');

  while GetField(fNumber) = movienumber do
    begin
		picture := TextBefore(DirList.GetString(0), #09, '');
		index := AddExtra;
		ImportExtraPicture(index, 'D:\MP\' + picture);
		SetExtraField(index, eCategory, 'Stills');
		DirList.Delete(0);
		movienumber := TextBetween(DirList.GetString(0), '_', '_');
	end;

  if GetIteration = GetIterationCount-1 then DirList.Free;
end.
have fun.

EDIT:
Fixed a little sorting thing.
fulvio53s03
Posts: 764
Joined: 2007-04-28 05:46:43
Location: Italy

Post by fulvio53s03 »

Please, where can i find function SetActualMovie ? :??:
Thanks.
:??:
Post Reply