INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Group Display Expression...  (Read 2558 times)

JeTie

  • Junior Woodchuck
  • **
  • Posts: 87
Group Display Expression...
« on: September 03, 2013, 05:53:45 pm »

19.0.32

I'm looking for a Display Expression which returns the common part of the filename from a group of similar filenames.

Options > Theater View > Items To Show...

I use an expression within a Library Item which is currently set up like this:
Expression to group by: Left([Filename (name)],10)
Expression to display: If(compare(GroupCount(), >, 1), [Name] /(GroupCount()/), [Name])

Example: two files, e.g.
  James Bond 21 Casino Royale
  James Bond 23 Skyfall
...end up grouped and captioned as...
  James Bond 23 Skyfall (2)

Is it possible to improve the display expression that it will return the common left part of the grouped filenames only, like...
  James Bond (2) 
?

I tried GroupSummary([Filename (name)]) but unfortunately it returns nothing.

Any ideas for a simple or more sophisticated solution?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Group Display Expression...
« Reply #1 on: September 03, 2013, 05:59:19 pm »

There's no LongestCommonString() function available, so this would be difficult.

However, why not use Series for movie series like these.  Your series would be James Bond, and you can use that for your grouping.
Logged
The opinions I express represent my own folly.

JeTie

  • Junior Woodchuck
  • **
  • Posts: 87
Re: Group Display Expression...
« Reply #2 on: September 04, 2013, 04:15:01 pm »

Using Series in this context requires constant maintenance wheras "LongestCommonString()" as you put it so very essentially would be just an "implement & forget it" solution. On the other hand Series is good enough because always only one objects series tag has to be filled after a new group is being recognized by the group expression:

Expression to group by: Left([Filename (name)],10)
Expression to display: If(compare(GroupCount(), >, 1), GroupSummary(Series) /(GroupCount()/), [Name])

--------
In the net I found a solution in PHP which would possibly do the job and serve at least as a good start for the display expression:
It compares strings $a, $b and returns $longest, e.g. abcdef, abcxef = abc
preg_match('/^'.preg_replace('/^(.\()(?=(.*)$)|\G.\(/','\1\2)?+',preg_replace('/(.)/','\1(',$a)).'/',$b,$longest);
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Group Display Expression...
« Reply #3 on: September 04, 2013, 05:00:17 pm »

The issue is not finding a long string within a single file's longer string.  The issue is finding a string across a single field in all files.  MC doesn't do this.

Your expressions only have access to a single file at a time*, so they cannot compare "James Bond For Your Eyes Only" from file1's [Name] field against "James Bond The Living Daylights" in file2's [Name] field.

* without some special global variable techniques.
Logged
The opinions I express represent my own folly.

JeTie

  • Junior Woodchuck
  • **
  • Posts: 87
Re: Group Display Expression...
« Reply #4 on: September 05, 2013, 03:04:44 am »

GroupSummary(Name) returns Various. Is there yet any detailed documentation available about the construct of that function?
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Group Display Expression...
« Reply #5 on: September 05, 2013, 11:02:42 am »

The functions are still a work in progress, so there's not much description yet.  I mentioned to Matt I'd write them up once he's settled down on the design.  I think some work (like this) has been somewhat sidelined while JRiver makes headway on other projects.

Basically the GroupSummary() function has some support for producing a finite number of summaries for given fields.  Summary would be defined like average duration of an album, number of tracks for an album, Various for a collection of names, etc.
Logged
The opinions I express represent my own folly.

JeTie

  • Junior Woodchuck
  • **
  • Posts: 87
Re: Group Display Expression...
« Reply #6 on: September 05, 2013, 12:56:24 pm »

OK, thanks so far for the quick resposes. Ciao
Logged
Pages: [1]   Go Up