# 42 character field length instead of 64

**URL:** https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168
**Category:** Support
**Created:** [December 11, 2006, 11:22pm UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168 "2006-12-11T23:22:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![level42](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/839c29/32.png) [@level42](https://community.mp3tag.de/u/level42)
#### Post date: [December 11, 2006, 11:22pm UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168/1 "2006-12-11T23:22:16Z")

</div>

I need to reduce the file length to 42 characters in length (incl. extension).

How can I format the Action line?

---

<div class="post-metadata">

### Author: ![Sebastian\_Mares](https://community.mp3tag.de/user_avatar/community.mp3tag.de/sebastian_mares/32/9285_2.png) [@Sebastian\_Mares](https://community.mp3tag.de/u/Sebastian_Mares)
#### Post date: [December 12, 2006, 7:28am UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168/2 "2006-12-12T07:28:55Z")

</div>

I think something like this should work:

```
$mid(%_filename_ext%,1,$sub(42,$add($sub($len(%_filename_ext%),$strrchr(%_filename_ext%,.)),1)))
```

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [December 12, 2006, 12:10pm UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168/3 "2006-12-12T12:10:27Z")

</div>

Another approach:

```
$left(%_FILENAME%,$sub(42,$sub($len(%_FILENAME_EXT%),$len(%_FILENAME%))))$right(%_FILENAME_EXT%,$sub($len(%_FILENAME_EXT%),$len(%_FILENAME%)))

```

will give the filename including extension.

```
$left(%_FILENAME%,$sub(42,$sub($len(%_FILENAME_EXT%),$len(%_FILENAME%))))

```

will give just the filename.

DD.20061212.1420

---

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [March 8, 2011, 12:50pm UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168/4 "2011-03-08T12:50:18Z")

</div>

Just to freshen up this old thread.

**How to shorten the filename to a specific length using Mp3tag Scripting Language?**

Goal:  
The length of the filename including extension should be 42 characters.  
From:  
02\_YouOughtaKnow~AcousticLive\_AlanisMorissette\_I\_1996.mp3  
To:  
02\_YouOughtaKnow~AcousticLive\_AlanisMo.mp3

Solution 1 _(will give the filename including extension)_:

**$left(%\_filename%,$sub(42,$sub($len(%\_filename\_ext%),$len(%\_filename%))))$right(%\_filename\_ext%,$sub($len(%\_filename\_ext%),$len(%\_filename%)))**

Solution 2:

**$mid(%\_filename\_ext%,1,$sub(42,$add($sub($len(%\_filename\_ext%),$strrchr(%\_filename\_ext%,'.')),1)))**

Solution 3:

**$left(%\_filename%,$sub(42,$sub($len(%\_filename\_ext%),$len(%\_filename%))))**

Solution 4 _(will give the filename including extension, like Solution 1)_:

**$left(%\_filename%,$sub(41,$len(%\_extension%)))'.'%\_extension%**

Solution 5:

**$left(%\_filename%,$sub(41,$len(%\_extension%)))**

DD.20110308.1455.CET

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:20pm UTC](https://community.mp3tag.de/t/42-character-field-length-instead-of-64/4168/5 "2026-02-09T12:20:02Z")

</div>


