Problems with dash in scripting functions

Hi,

I'm trying to perform a fairly simple operation - take a filename which is Artist 1, Artist 2 - Title and populate the Artist field with "Artist 1 || Artist 2"

I'm working using Actions here so that I can easily repeat the operation.
Originally I split the filename by "-", but ran into an issue with artists like T-Pain, so thought to use the Format Value Action and split on " - " instead. I was going to use $strstr to identify where the split is, $left to take only the Artists and finally $replace to swap commas for ||.

The trouble was it didn't work - $strstr could find "- " and "-", but not " - " in the filename.

Perhaps the first space isn't really a space you think, so I split the operation into 3 separate actions;

  1. Copy the filename into a user defined tag
  2. Use Replace on the new tag to swap " - " for "x-x"
  3. Use the complex operation described above involving $strstr to locate x-x and truncate the string etc.

But now despite 1 & 2 working fine, operation 3 could not locate "x-x". It IS there, and my syntax in 3 is correct because if I swap "x-x" for another 3 character string located in that artist, it works!

So it appears that $strstr has an issue with dashes unless a dash is the first character of the string it is looking for.

Are you sure that it is always the same dash-charcater?
https://en.wikipedia.org/wiki/Wikipedia:Hyphens_and_dashes

You can easily test this by not writing the dash but c&p it from the source.
You can also test $strstr() by defining a column with the value $strstr(%_filename%, - ).

Why are you not using the action-type "Guess Values" to populate the artist-tag directly?

Try this formatstring ...

$replace($left('Artist 1, Artist 2 - Title',$sub($strstr('Artist 1, Artist 2 - Title',' - '),1)),', ',' || ',)

resp.

$replace($left(%_filename%,$sub($strstr(%_filename%,' - '),1)),', ',' || ',)

If you suspect any dash ambiguity then find there something useful ...
/t/16483/1
/t/15410/1

DD.20180128.1250.CET