Sort->MediaLabel

If you need help on how to use the program
Post Reply
Scriabin
Posts: 5
Joined: 2007-02-27 12:28:37

Sort->MediaLabel

Post by Scriabin »

Hi all first, this is my debut in this forum.
Let's see my problem: it happens when I try to sort my database by MediaLabel variable.
here's the screenshot:

Image

The numbers are not ordered as you can see: 10 must be after 9 and not just after 1, the same for 100...it should be after 99 but it's just after 10.
If I try to export the database I obtain the same type of sorting.
I need it to be 1-2-3.....9-10-11.....99-100-101.... and not 1-10-100-101...and so on.
what's wrong?
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

Nothing's wrong ;)

I think it is because MediaLabel is no 'integer' but some kind of 'string' variable, and then it is the normal behaviour. In MediaType field you cannot use numbers only, but all kind of letters. Sorting will start with the first letter of the word (or integer), then read the second one, third one - and so on.

You should add some leading '0' if you want to get a proper listing.

001
002
...
010
011
..

But maybe I'm wrong and there is a better solution ? ;)
Scriabin
Posts: 5
Joined: 2007-02-27 12:28:37

Post by Scriabin »

it's a hard hard work...I have to change my over three hundred labels in something like 0001-0002...? :cry:
I hope there's a better solution...
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

This can be done easily using a script, I think that I posted that somewhere on the forum some time ago.
I do not have time right now, I'll post it within 1h if you haven't found it until then.
Scriabin
Posts: 5
Joined: 2007-02-27 12:28:37

Post by Scriabin »

I've tried a lot of searches in this forum, maybe the wrong words...
Thanks in advance for your help
:D
antp
Site Admin
Posts: 9630
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

OK so here is it:

Code: Select all

program NewScript;
var
  s: string;
begin
  s := GetField(fieldMedia);
  if s <> '' then
  begin
    while Length(s) < 4 do
      s := '0' + s;
    SetField(fieldMedia, s);
  end;
end.
Go to tools -> scripting, or press F6.
Be sure that in "script limitations" you have checked "all" (or "selected" if you want to modify only the selected movies).
In the "editor" tab click the "new" icon and replace the script template by the one above.
The click run and it should be done ;)
(you can reply "no" when the program asks if you want to save the script, except if you want to reuse it later)
Scriabin
Posts: 5
Joined: 2007-02-27 12:28:37

Post by Scriabin »

Wonderful, it works!!!!!!!!!!!!! :clapping:
Post Reply