# how to trim filename?

**URL:** https://community.mp3tag.de/t/how-to-trim-filename/18542
**Category:** General Discussion
**Created:** [December 24, 2016, 7:03am UTC](https://community.mp3tag.de/t/how-to-trim-filename/18542 "2016-12-24T07:03:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![X-Tropic](https://community.mp3tag.de/user_avatar/community.mp3tag.de/x-tropic/32/7536_2.png) [@X-Tropic](https://community.mp3tag.de/u/X-Tropic)
#### Post date: [December 24, 2016, 7:03am UTC](https://community.mp3tag.de/t/how-to-trim-filename/18542/1 "2016-12-24T07:03:26Z")

</div>

Filename: Jay\_Mexx\_-_Plastic_(Original\_Mix)\_[Deep\_Records-DRS245]

Need output: Jay\_Mexx\_-_Plastic_(Original\_Mix)\_[Deep\_Records]

How to use $trimRight for remove "catalog number" from filename, including "-" ?

---

<div class="post-metadata">

### Author: ![X-Tropic](https://community.mp3tag.de/user_avatar/community.mp3tag.de/x-tropic/32/7536_2.png) [@X-Tropic](https://community.mp3tag.de/u/X-Tropic)
#### Post date: [December 24, 2016, 7:08am UTC](https://community.mp3tag.de/t/how-to-trim-filename/18542/2 "2016-12-24T07:08:17Z")

</div>

Maybe:

in: %1[%2-%3]

out: %1'['%2']'

How to make this action for batch processing?

---

<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 24, 2016, 11:06am UTC](https://community.mp3tag.de/t/how-to-trim-filename/18542/3 "2016-12-24T11:06:22Z")

</div>

> [@X-Tropic](#):
>
> Filename: Jay\_Mexx\_-_Plastic_(Original\_Mix)_[Deep\_Records-DRS245]  
> Need output: Jay\_Mexx_-_Plastic_(Original\_Mix)\_[Deep\_Records]  
> ... remove "catalog number" from filename, including "-" ?

For sure set Mp3tag Filter to ...  
"%_FILENAME%" MATCHES "^(.+?_[.+?)-.+?(])$"

... then apply "Convert Tag - Tag" ...  
... or Action "Format value" ...  
Field: \_FILENAME  
Formatstring: $regexp(%_FILENAME%,'^(.+?_[.+?)-.+?(])$','$1$2')

... or ...  
in case of the trailing sequence has always the same length, ...  
then apply "Convert Tag - Tag" ...  
... or Action "Format value" ...  
Field: \_FILENAME  
Formatstring: $cutRight(%\_FILENAME%,8)']'

DD.20161231.1313.CET

---

<div class="post-metadata">

### Author: ![X-Tropic](https://community.mp3tag.de/user_avatar/community.mp3tag.de/x-tropic/32/7536_2.png) [@X-Tropic](https://community.mp3tag.de/u/X-Tropic)
#### Post date: [December 24, 2016, 5:06pm UTC](https://community.mp3tag.de/t/how-to-trim-filename/18542/4 "2016-12-24T17:06:28Z")

</div>

Big thanks, **DetlevD**!

Field: \_FILENAME  
Formatstring: $regexp(%_FILENAME%,'^(.+?_[.+?)-.+?(])$','$1$2')

works fine!

How add whitespace character in your formatstring?

i have mixed files... for example:

Jay\_Mexx\_-_Plastic_(Original\_Mix)\_[Deep\_Records-DRS245]

Jay Frog - Dream (Original Mix) [Groove Records-GR054]

etc...
