Page 1 of 1

Can a script be used to truncate fields at a certain point?

Posted: 2013-07-27 11:36:38
by daws0n
I've decided that IMDB's multiple category function is a bit too detailed/OTT for my collection. However, I've used it for years so there's a lot of entries to change!

I see that IMDB's simple/single category function simply takes the first value and ignores all others which is what I'd prefer.

e.g

"Adventure / Biography / Drama / History / War"

simply becomes

"Adventure"

Rather than resorting to the IMDB script to accomplish this and eating bandwidth, are there any scripting functions I could use to truncate the detailed entries I already have?

So, all over values after the first instance of "/" are erased in the category field?

Thanks!

Posted: 2013-07-27 11:53:26
by soulsnake
Hi,

You can use the little script below to keep only the first value in field category.
Run this script on all your movies and it is done ;).

Code: Select all

program KeepOnlyFirstValueInFieldCategory;
var
  s: string;
  i: Integer;
begin
  s := GetField(fieldCategory);
  i := Pos('/', s);
  if i = 0 then
    i := Pos(',', s);
  if i = 0 then
    i := Pos(';', s);
  if i > 0 then
  begin
    s := Copy(s, 1, i-1);
    s := Trim(s);
    SetField(fieldCategory, s);
  end;
end.
Soulsnake.

Posted: 2013-07-27 12:03:41
by daws0n
Works a treat, thank you very much! :)