Page 1 of 1

Adding genres on certain films

Posted: 2011-01-07 11:21:18
by z3us
I want to add genre "saw" to all films containing "saw" in the translated title. Is it possible?
I know they are only 6, but I would like to know how to do similar operations when needed

Thanks

Posted: 2011-01-08 00:48:04
by antp
here it is:

Code: Select all

program NewScript;
var s: string;
begin
  s := GetField(fieldTranslatedTitle);
  if Pos('saw', AnsiLowerCase(s)) > 0 then
    SetField(fieldCategory, 'saw');
end.
Here I use "Pos" function to see where 'saw' appears in the text, and if it appears (position > 0) I set the other field.
Note that I use AnsiLowerCase on the title text to convert it to the same case as the searched text because by default if you search 'saw' in the title 'Saw IV' for example, it won't find it. The search is case-sensitive.

Posted: 2011-01-08 13:03:40
by z3us
But that script will replace the whole cattegory field for "saw" Wont it?
I want to add, so if the original cattegory field is "Terror", it would be changed to "Terror, saw"

Posted: 2011-01-08 13:36:48
by Raoul_Volfoni
z3us wrote:But that script will replace the whole cattegory field for "saw" Wont it?
Yes
z3us wrote:I want to add, so if the original cattegory field is "Terror", it would be changed to "Terror, saw"
In that case

Code: Select all

program NewScript;
var s: string;
begin
  s := GetField(fieldTranslatedTitle);
  if Pos('saw', AnsiLowerCase(s)) > 0 then
    SetField(fieldCategory, GetField(fieldCategory)+', Saw');
end.

Posted: 2011-01-08 16:21:09
by z3us
Thanks, Ill test later