# Error Using $cutright, $mid, $left with $len

**URL:** https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290
**Category:** Support
**Created:** [June 18, 2023, 2:35pm UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290 "2023-06-18T14:35:34Z")
**Posts on this page:** 7
**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 18, 2023, 2:35pm UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/1 "2023-06-18T14:35:34Z")

</div>

![mp3tag-len-error-18-06-2023 14-43-15](https://community.mp3tag.de/uploads/default/original/2X/8/8208e7488282e2b4fb594ad70b5b9cd703b5606e.png)

 ![mp3tag-len-error-18-06-2023 14-32-45](https://community.mp3tag.de/uploads/default/original/2X/0/08a65415cb3d07e9a90ceab05a20ef47fbe02a5e.png)  
 ![mp3tag-left-len-error-18-06-2023 14-17-58](https://community.mp3tag.de/uploads/default/original/2X/7/79cc623e6175cec6b6ff9b56e1b20a42cd4970e6.png)  
 ![mp3tag-left-len-error-18-06-2023 14-12-51](https://community.mp3tag.de/uploads/default/original/2X/9/9d1aa5151c79b587ea81cbae1089b1557ecb2bd2.png)

the fix is simple enough logically - i simply wanted too truncate the Title by 65 chars ie removethe last chars of title

1. of course with data like this the Title length ie $len is totally variable so no fixed parameters can be used
2. there is no simple $truncate function
3. NONE of $left, $mid, or $cutright would work with $len to remove the last 6 chars  
see various attached examples
4. if i used $len with another PH, eg Artist, it worked, ie, if i wanted, i could truncate the Title by the length of the Artist field, which is fine - if you want to do that
5. but if you want to take a fixed number of the length to KEEp ie in this case Title Length - 6, no combination would work
6. it just didn't do anything, ie THIS is what would not work ... eg %title, $len(%title)-6. as per attachments, no matter which function i used
7. as i think i might have said before, a $TRUNC(x,n or field) function would be so much eaisr

PS i find i have to be ultra careful because i am using MP3Tag and AIMP Tag Edfitor and Bulk Rename Utility, simultaneously, and the PH and functions are very similar - but different. very easy to get them mixed up when using  
, the '-6' would not work  
.

---

<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 18, 2023, 2:44pm UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/2 "2023-06-18T14:44:13Z")

</div>

To subtract values, use $sub()  
See the documentation:

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#arithmetic-functions)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 19, 2023, 6:19am UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/3 "2023-06-19T06:19:47Z")

</div>

> [@dec](#):
>
> the fix is simple enough logically - i simply wanted too truncate the Title by 65 chars ie removethe last chars of title

You write in the topic title, that `$cutright` does not work for you.

If I try it with your mentioned track title  
`Twenty Tiny Fingers (Alma Cogan) (The Fabulous Fifties - Thest of the Fab 50s) (2005) (144kbits)158453`

I get this in the preview of Convert Tag-\>Tag  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/e/e31bcee93fc55caacf74ecd4f52e7d141256f21b.png)  
Why should this not work for you?

From the already linked documentation:

 ![image](https://community.mp3tag.de/uploads/default/original/2X/1/1fc23df20f69c98aa1da399e30c531662ba8c688.png)

If you want to solve it with an Action, you could try "Format value":  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/b/b667d5432b3f9459d330e37ca26b08496a06e34d.png)

* * *

> [@dec](#):
>
> NONE of $left, $mid, or $cutright would work with $len to remove the last 6 chars  
> see various attached examples

If you need to cut a variable number of characters with the length of ARTIST, this would work too:  
_(this example assumes, that the current content of ARTIST has 6 characters)_  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/0/0f4eee8d3f763855c541e2e8e9bb8e64e275f8a0.png)

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 19, 2023, 6:49am UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/4 "2023-06-19T06:49:44Z")

</div>

> [@dec](#):
>
> as i think i might have said before, a $TRUNC(x,n or field) function would be so much eaisr

Usually, a TRUNC function only returns a number truncated to a specified number of digits.  
It is not applicable to text in most variants.

The `$cutRight(x,n)` and `$cutLeft(x,n)` scripting functions of Mp3tag does exactly what you are looking for:  
Removing the last or first `n` characters of the string `x` = returning the "truncated" string

---

<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, 12:09pm UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/5 "2023-06-22T12:09:20Z")

</div>

this might help me.

let me check. i have tried sooo many variations ...

now on this ppint, i was trying something, but was apparently stymied because it didn't take a PH variable .... let me find that to show you,  
and so the next thing was how to achieve the desired result without using a PH directly...

i will come back and paste image

![image](https://community.mp3tag.de/uploads/default/original/2X/9/90511e804f1b44d2286a86fd2153c85611f8dc8e.png)

so what do you do instead?

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [June 22, 2023, 12:33pm UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/6 "2023-06-22T12:33:23Z")

</div>

Please don't cross-post!  
(You have already asked the same in [this thread](https://community.mp3tag.de/t/odd-replace-treats-artist-as-a-literal/61321))

Use an action " **Format value**" to rename your track filenames.  
Don't use "Replace" as @poster [already told you](https://community.mp3tag.de/t/odd-replace-treats-artist-as-a-literal/61321/6).

Use a format string with something like this:  
`$num(%TRACK%,2). $cutRight(%ARTIST%,9) - %TITLE%`

 ![image](https://community.mp3tag.de/uploads/default/original/2X/d/d39cecc7be3191bacd5feaa6fdc75b36a04ac1d8.png)  
This would result in a filename like:  
`01. Abba - Waterloo.mp3`

Or just reduce the format string to your example  
`%ARTIST%`  
if you only want to see the full content of ARTIST as your new track filename.  
For my above example this would result in this trackname:  
`Abba and more.mp3`

---

<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:34am UTC](https://community.mp3tag.de/t/error-using-cutright-mid-left-with-len/61290/7 "2023-06-23T09:34:07Z")

</div>


