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

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

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

Post 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!
soulsnake
Posts: 756
Joined: 2011-03-14 15:42:20
Location: France

Post 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.
Last edited by soulsnake on 2013-07-27 12:12:31, edited 1 time in total.
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Post by daws0n »

Works a treat, thank you very much! :)
Post Reply