# How to replace a specific word at the end of FILENAME?

**URL:** <https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210>\
**Category:** Support\
**Created:** [May 4, 2022, 8:16pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210 "2022-05-04T20:16:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [May 4, 2022, 8:16pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/1 "2022-05-04T20:16:35Z")

</div>

I need to replace `_xxx` at the end of any audio format with nothing [every `_` sign stands in this post for mine for a pause, because this forum will does not allow to show multiple pauses]  
` `  
` `  
So for example

`Title Of Song xxx.flac`

becomes

`Title Of Song .flac`

but

`Title Of Songxxx.flac`

stays as

`Title Of Songxxx.flac`

[i.e. lack of pause acting a fail-safe]  
` `  
` `

And also

`Title Of Song 2__xx.mp3`  
`Title Of Song 2___XXX.mp3`

become

`Title Of Song 2__.mp3`  
`Title Of Song 2___.mp3`

but

`Title Of Song 2xx.mp3`  
`Title Of Song 2XXXX.mp3`

stay as

`Title Of Song 2xx.mp3`  
`Title Of Song 2XXXX.mp3`  
` `  
` `  
So how do I do this?

---

<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:** [May 4, 2022, 8:34pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/2 "2022-05-04T20:34:55Z")

</div>

You could try:  
`$regexp('Title Of Song xxx',(.*)\s+xxx,$1)`

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [May 5, 2022, 11:55am UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/3 "2022-05-05T11:55:04Z")

</div>

I think I should also have precised, that it should work for any titles / filenames, and not just literally for `Title Of Song`  
` `  
` `  
Modifying this Format Value to

> `$regexp(' xxx',(.\*)\s+xxx,$1)

makes the whole `_FILENAME` disappear, leaving only the extension; even when there is no `xxx` present at all in it

---

<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:** [May 5, 2022, 12:14pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/4 "2022-05-05T12:14:07Z")

</div>

> [@Zerow](#):
>
> Modifying this Format Value to
> 
> > `$regexp(' xxx',(.\*)\s+xxx,$1)

This makes no sense at all if you want to modify the filename - as this look in the string " xxx" for at least 1 space character and "xxx" which produces an empty string in `(.*)` and therefore deletes the filename.

So, please, instead of the string constant in your examples (and my reply) use the property variable %\_filename%.

---

<div class="post-metadata">

**Author:** ![Zerow](https://community.mp3tag.de/user_avatar/community.mp3tag.de/zerow/32/11379_2.png) [@Zerow](https://community.mp3tag.de/u/Zerow)\
**Post date:** [May 5, 2022, 12:45pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/5 "2022-05-05T12:45:41Z")

</div>

OK, those two variations seem to work as I need it them to do:

> $regexp(%\_FILENAME%,(.\*)\s+xxx,$1)

> $regexp(%\_FILENAME%,(.\*)\s+XXX,$1)

` `  
` `  
So, thank you

---

<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:** [June 4, 2022, 12:46pm UTC](https://community.mp3tag.de/t/how-to-replace-a-specific-word-at-the-end-of-filename/57210/6 "2022-06-04T12:46:03Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
