INTERACT FORUM

Please login or register.

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

Author Topic: Can I use expressions to create a smartlist?  (Read 1753 times)

pqcgebxm

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 71
  • nothing more to say...
Can I use expressions to create a smartlist?
« on: September 16, 2017, 11:28:24 am »

I'm a bit confused about how the expression language can be used. I want to make a smartlist which includes all music files which have both an Album Artist and an Artist defined and where the Album Artist is equal to the Artist. In other words, I need to compare two fields. Since there is no standard rule for this, I thought I could create a custom rule using the "import" button, like this:

Code: [Select]
field("Album Artist") = field("Artist")
or

Code: [Select]
isequal(field("Album Artist"), field("Artist"))
But when I save the custom field, it does not work and the above text is not even saved in the same format. I also tried a more simple comparison, like this:

Code: [Select]
albumartist=artist
But in this case, "albumartist" is treated as a field name but "artist" is treated as a simple string.

So, it seems like the expression language cannot be used for smartlists. Is this correct, or am I doing something wrong? If I can't use expressions, how can I create a list like I've described?
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Can I use expressions to create a smartlist?
« Reply #1 on: September 16, 2017, 11:38:46 am »

You're on the right track.  This is just one of those instances where the syntax of the Expression Language is a little wonky.

What you want to do is create a rule in your smartlist of type Custom.  Then enter an expression something like this:

Code: [Select]
[=isequal([artist],[album artist],1)]=1
You can also paste that into the Import/Export dialog as you did previously.

The keys are the surrounding square brackets and the test for "=1" at the end.  I can explain the syntax further if you'd like.  Otherwise, just use that as a template and adapt it as you require.

Good luck,

Brian.
Logged

pqcgebxm

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 71
  • nothing more to say...
Re: Can I use expressions to create a smartlist?
« Reply #2 on: September 17, 2017, 02:37:34 am »

Thanks! That worked a treat.

I didn't see this additional syntax documented anywhere when searching through the smartlist, search syntax or expression syntax documentation. It would be useful for this to be added to the wiki.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8948
Re: Can I use expressions to create a smartlist?
« Reply #3 on: September 17, 2017, 03:36:42 am »

It's there already... on this page... https://wiki.jriver.com/index.php/Expression_Language

Near the bottom...
Quote
Expressions and Search

The expression language is fully available to the search query engine (Search, Set rules for file display, etc.). This allows creation of more complex search queries than would otherwise be possible. An expression-based search query is any valid expression that produces a zero or non-zero numeric output. The syntax of the query is:
[=expression]=numval

where expression is any valid expression, and numval is the expected numeric output produced by the expression. The expression is evaluated against the current list of available files and the expression output numerically compared against numval. All files for which the comparison is true are returned as part of the file list produced by the query and all files that fail the comparison are winnowed from the file list.

The following example illustrates an expression-based search query:
[=ismissing([filename (path)]\Folder.jpg)]=1

The IsMissing() function is run using the file name argument [filename (path)] appended by \Folder.jpg, and returns a Boolean value 1 for files that are missing, and this 1 is compared against the value numval. All these files where there was a successful comparison are returned in the file list, and all those for which the expression produced 0 are filtered from the file list. By inverting the comparison and using a 0 numval, the set of files remaining in the file list would be those that did not match.
Pages: [1]   Go Up