# Odd STRCHR Error

**URL:** <https://community.mp3tag.de/t/odd-strchr-error/61310>\
**Category:** Support\
**Created:** [June 20, 2023, 1:45pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310 "2023-06-20T13:45:18Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dec](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dec/32/13699_2.png) [@dec](https://community.mp3tag.de/u/dec)\
**Post date:** [June 20, 2023, 1:45pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/1 "2023-06-20T13:45:18Z")

</div>

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](https://community.mp3tag.de/uploads/default/original/2X/e/e3bde0cccee501db26b05b8bf05b7503bbfe3559.png)  
 ![mp3tag-strchr-correct-4](https://community.mp3tag.de/uploads/default/original/2X/2/2a3be0e90b35459b351eadb99ccc1e9be7c62338.png)  
 ![mp3tag-strchr-errors-3](https://community.mp3tag.de/uploads/default/original/2X/2/23b148c7b74d7d81f3df33581a90ce6e6ec43adf.png)

 ![mp3tag-strchr-error-2](https://community.mp3tag.de/uploads/default/original/2X/0/0e25a5e5c2b30cb682747662062e703d4e1e3403.png)  
 ![mp3tag-strchr-error-1](https://community.mp3tag.de/uploads/default/original/2X/d/d2886daab0a643d6aa998eb974e5cd16f1cc7c63.png)

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 20, 2023, 1:53pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/2 "2023-06-20T13:53:37Z")

</div>

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%`

---

<div class="post-metadata">

**Author:** ![dec](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dec/32/13699_2.png) [@dec](https://community.mp3tag.de/u/dec)\
**Post date:** [June 21, 2023, 2:17pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/3 "2023-06-21T14:17:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 21, 2023, 2:43pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/4 "2023-06-21T14:43:50Z")

</div>

"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

> [@dec](#):
>
> Cutright cuts to a completely different position than Cutright

is confusing.

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [June 21, 2023, 3:39pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/5 "2023-06-21T15:39:06Z")

</div>

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.

> [@ohrenkino](#):
>
> If that set of functions does not work for you - have you tried "Guess value" with  
> Source string: `%_filename%`  
> Target string: `%artist% - %dummy%`

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.

---

<div class="post-metadata">

**Author:** ![dec](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dec/32/13699_2.png) [@dec](https://community.mp3tag.de/u/dec)\
**Post date:** [June 21, 2023, 4:31pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/6 "2023-06-21T16:31:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 21, 2023, 4:40pm UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/7 "2023-06-21T16:40:11Z")

</div>

$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%,-))`

---

<div class="post-metadata">

**Author:** ![dec](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dec/32/13699_2.png) [@dec](https://community.mp3tag.de/u/dec)\
**Post date:** [June 22, 2023, 4:35am UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/8 "2023-06-22T04:35:31Z")

</div>

> [@ohrenkino](#):
>
> $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.

---

<div class="post-metadata">

**Author:** ![dec](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dec/32/13699_2.png) [@dec](https://community.mp3tag.de/u/dec)\
**Post date:** [June 22, 2023, 10:32am UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/9 "2023-06-22T10:32:22Z")

</div>

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,

 ![mp3tag-title-extract-title-22-06-2023 16-51-34](https://community.mp3tag.de/uploads/default/original/2X/1/1b5cc563bd73039a1b785c5ac4f19f290ba4cfab.png)  
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 🙂

forgot the attachment too

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 22, 2023, 10:39am UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/10 "2023-06-22T10:39:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [June 23, 2023, 9:35am UTC](https://community.mp3tag.de/t/odd-strchr-error/61310/11 "2023-06-23T09:35:04Z")

</div>


