Adding genres on certain films

If you need help on how to use the program
Post Reply
z3us
Posts: 86
Joined: 2008-02-19 17:36:53

Adding genres on certain films

Post 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
antp
Site Admin
Posts: 9668
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post 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.
z3us
Posts: 86
Joined: 2008-02-19 17:36:53

Post 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"
Raoul_Volfoni
Posts: 863
Joined: 2006-08-31 23:58:18

Post 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.
z3us
Posts: 86
Joined: 2008-02-19 17:36:53

Post by z3us »

Thanks, Ill test later
Post Reply