Odd STRCHR Error

i found a whole lot of files w/o Artist, for some reason, although it is in Filename, and fortutiously has a '-' separator

but i cannot get $strchr (with Cutright) to play nicely to extract the Artist precisely from Filename

it seems quite weird.
if i use Cutleft it extracts the rest of the Filename string exactly
if i use Strrchr, it makes no difference ie it cuts to exactly the same place (meaning that there is only one in the string)
but Cutright cuts to a completely different position than Cutright.
mp3tag-strchr-error-5
mp3tag-strchr-correct-4
mp3tag-strchr-errors-3


Have you tested which result you get from $strchr()? (Billie Holiday only accidentally gets the correct result as that name is just as long as "strange fruit")
And have you tried that number with a plain $cut...() function?

If that set of functions does not work for you - have you tried "Guess value" with
Source string: %_filename%
Target string: %artist% - %dummy%

just quickly: i have not (ever) tried 'Guess Value' as i find the name very odd and puts me right off, and do i do not understand what it does

i will revist this shortly to refresh my memory and retest

"Guess value" was only a suggestion as you seem to have also problems with the functions $cutleft() and $cutright() - the result that you expect could be achieved with the function $left().

The statement

is confusing.

The cut functions have a dependence on an absolute length, even if that value is derived from another length calculation. This may end up getting the desired results, but isn't the cleanest approach.

The Guess Values funcion is far more precise, and does not depend on values. But it does depend on having some clearly identifiable method of separation. In your example, this sepearation is space dash space " - " and helps to define from what I believe is your file name, into both the artist and title.

The method was already outlined above, I suggest you try this.

Note that the separator is literal. If any files you select and apply this action to does not have " - " as the actual separator, no results will be found. You will then have to resort to changing the action to reflect whatever truly defines the gap between fields.

huh? as per screenshot, $cutright does NOT cut to the expected position ie to the '-', but somehwre completely different. as per teh screenshot/s.

$cutright does not "cut from the right" but - as the documentation tells you:

$cutRight(x,n) removes the last n characters of string x and returns the result.

The accidental result with Billie Holiday only works because the part in front of the hyphen is just as long as the part behind it.
Bill Withers has the hyphen at position 14 and if you remove the 14 characters on the right with $cutright() you end up with the string shown in the preview.
If you want to cut the filename so that only the part up to the hyphen remains, then use $left(%_filename%,$strchr(%_filename%,-))

i tried so many variations, i can't recall what i tried.
anyway, i wil save this string as an Action for future use.

Thank you.

that parsing was the easy one
btw, changed to Strstr and changed to ' -', and then used Trim to get rid of remaining trailing blank

as per attached,


next is harder for me. i tried %dummy% but it won't work becuase the artist name in filename of course vary a lot

so as per attached, i am trying to extract the Title out of the File name, but no success yet

but i am sure you (or Motley) could do straight away, so i wil lbe very interested how you do it :slight_smile:

forgot the attachment too

1 Like

Is this a new problem? Then please open a new thread.