# flac.flac / mp3.mp3

**URL:** <https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860>\
**Category:** Support\
**Created:** [April 17, 2016, 1:23pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860 "2016-04-17T13:23:54Z")\
**Posts on this page:** 19\
**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:** [April 17, 2016, 1:23pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/1 "2016-04-17T13:23:54Z")

</div>

I would like to know, if Mp3tag supports manipulation of the file extension?

Very rarely I somehow end up with files that have filename like  
Abc **flac.flac**  
instead of  
Abc **.flac**  
or  
X Y Z **mp3.mp3**  
instead of  
X Y Z **.mp3**

So I tried to create an action to take care of this: some kind of format value for the "\_FILENAME" with the "trim". But it seems that "\_FILENAME" in Mp3tag means literally filename and not filename + extension. And so such an action would be impossible to work as I would like it to work [and I need to take some other approach]

---

<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:** [April 17, 2016, 1:34pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/2 "2016-04-17T13:34:09Z")

</div>

> [@zerow](#):
>
> ... But it seems that "\_FILENAME" in Mp3tag means literally filename and not filename + extension. ...

See the pseudo-variable %\_filename\_ext% which includes the extension and see if you do something with it.

---

<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:** [April 17, 2016, 1:46pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/3 "2016-04-17T13:46:19Z")

</div>

> [@zerow](#):
>
> I would like to know, if Mp3tag supports manipulation of the file extension? Very rarely I somehow end up with files that have filename like  
> Abc **flac.flac** instead of Abc **.flac**  
> or  
> X Y Z **mp3.mp3** instead of X Y Z **.mp3**...

As your example show, there is only the need to remove trailing text from the filename, where the trailing text contains the name of the file extension, e .g. ' flac' or ' mp3'.  
Apply functions like $regexp, $cutRight, $left, $replace, $if, $eql, $ifgreater, and variables like %\_filename% and %\_extension%.

Examples ...

**\_FILENAME \<== $replace(%\_filename%'$',' '%\_extension%'$',)****\_FILENAME \<== $trimRight($replace(%\_filename%'$',%\_extension%'$',))****\_FILENAME \<== $regexp(%\_filename%,'\s+'%\_extension%'$',)****\_FILENAME \<== $regexp(%\_filename%,'(\s\*'%\_extension%')\*$',)**

But it would be better you check the other code, which have introduced the failure.

DD.20160417.1804.CEST, DD.20160505.1656.CEST

---

<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:** [April 17, 2016, 2:33pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/4 "2016-04-17T14:33:21Z")

</div>

> [@zerow](#):
>
> [...]  
> But it seems that "\_FILENAME" in Mp3tag means literally filename and not filename + extension  
> [...]

> [@ohrenkino](#):
>
> See the pseudo-variable %\_filename\_ext% which includes the extension and see if you do something with it.

I replaced the \_FILENAME with \_FILENAME\_EXT in four of variation of my action. And now they do nothing [in opposition to doing it wrong]

So this simple trick does not work in this case

> [@DetlevD](#):
>
> As your example show, there is only the need to remove trailing text from the filename, where the trailing text contains the name of the file extension, e .g. ' flac' or ' mp3'.

I simply don't know what trailing text is. [I lack some in my English]

> [@DetlevD](#):
>
> Apply functions like $regexp, $cutRight, $left, $replace, $if, $eql, $ifgreater, and variables like %\_filename% and %\_extension%.

But I'm deducting that you mean that I have to take care only of the filename and not filename + extension

But the problem with that is that there could be some song title which goes  
Something, Something, **WAW.vw** Some More Gibberish Blabla **flacflac**  
And so I would not end up later on with a correct filename  
Something, Something, **WAV.vw** Some More Gibberish Blabla **flacflac.flac**  
but with a  
Something, Something, **WAV** Some More Gibberish Blabla **.flac**  
or even [if I were to add more file extension to the equation] with  
Something, Something, Some More Gibberish Blabla **.flac**

I know that this is unlikely and I should present some more possible [not so gibberish] example. But I always try to think how a change / code can go wrong, and not about those 99.9% easy cases, where it will work perfectly. And I just know that once I put something to my actions, I simply forget what [how much do] the do; ans so after a while I would make more and more of unneeded changes

So if the direction to take was to "look at the end of only the filename and even only there make the change", there still would be room for unwanted change of the actual end of a title. Or am I wrong on that?

---

<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:** [April 17, 2016, 3:22pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/5 "2016-04-17T15:22:11Z")

</div>

> [@zerow](#):
>
> ...But I always try to think how a change / code can go wrong, and not about those 99.9% easy cases, where it will work perfectly. ...

As language is not logical you will always have ambiguities.  
Why don't you simply rewrite the filename of those files?

---

<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:** [April 17, 2016, 3:22pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/6 "2016-04-17T15:22:18Z")

</div>

> [@zerow](#):
>
> ... I simply don't know what trailing text is.

The meaning is: "trailing" or "appended" as the opposite of "leading" or "prepended".

- Буксируемый текст, Добавлен текст
- Ведущий текст, Предваряет текст

> [@zerow](#):
>
> ... But I'm deducting that you mean that I have to take care only of the filename and not filename + extension ...

Yes.

> [@zerow](#):
>
> ..  
> But the problem with that is that there could be some song title which goes  
> Something, Something, **WAW.vw** Some More Gibberish Blabla **flacflac**  
> And so I would not end up later on with a correct filename  
> Something, Something, **WAV.vw** Some More Gibberish Blabla **flacflac.flac**  
> but with a  
> Something, Something, **WAV** Some More Gibberish Blabla **.flac**  
> or even [if I were to add more file extension to the equation] with  
> Something, Something, Some More Gibberish Blabla **.flac**...

Well, this looks like as there is some serious error in the other actions, which create the filename.

DD.20160417.1922.CEST

---

<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:** [April 18, 2016, 9:29am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/7 "2016-04-18T09:29:18Z")

</div>

> [@ohrenkino](#):
>
> As language is not logical you will always have ambiguities.  
> Why don't you simply rewrite the filename of those files?

Because I would need to spot them first

Of course I can put "flac.flac" in the filter; and then make manually the change. But that's what actions are for: they take care of repetitive tasks

But I don't understand that duplicity: extensions by \_FILENAME and \_FILENAME\_EXT are not "seen" by actions; but the filter takes notice of extensions of files

---

<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:** [April 18, 2016, 10:12am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/8 "2016-04-18T10:12:23Z")

</div>

> [@zerow](#):
>
> ...But I don't understand that duplicity: extensions by \_FILENAME and \_FILENAME\_EXT are not "seen" by actions; but the filter takes notice of extensions of files

THis is not quite correct:  
for "Replace with regular expression" it is specified:

"Note: At this action \_FILENAME applies to the whole file name including its extension. "  
[https://docs.mp3tag.de/actions/replace-regexp](https://docs.mp3tag.de/actions/replace-regexp)

---

<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:** [April 18, 2016, 5:14pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/9 "2016-04-18T17:14:26Z")

</div>

> [@ohrenkino](#):
>
> [...]  
> for "Replace with regular expression" it is specified:
> 
> "Note: At this action \_FILENAME applies to the whole file name including its extension. "  
> [...]

I came up with  
Regular expression "\_FILENAME" $Right(.flac{n,}) - \> flacbut it doesn't 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:** [April 18, 2016, 5:41pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/10 "2016-04-18T17:41:57Z")

</div>

is that a ...

> [@zerow](#):
>
> Regular expression "\_FILENAME" $Right(.flac{n,}) - \> flac

?  
I think that you have to use something like (\*.\d),$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:** [April 19, 2016, 2:57am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/11 "2016-04-19T02:57:51Z")

</div>

> [@zerow](#):
>
> I came up with Regular expression "\_FILENAME" $Right(.flac{n,}) - \> flac ...

This is botch.

You are about to run into the wild.  
If you remove the filetype extension, then the files probably become invalid.  
See post #3 in this thread, where I told you to modify the filename, but not the extension.

DD.20160419.0657.CEST

---

<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:** [April 21, 2016, 10:52am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/12 "2016-04-21T10:52:35Z")

</div>

> [@zerow](#):
>
> [...]
> 
> ```
> Regular expression "_FILENAME" $Right(.flac{n,}) - > flac
> 
> ```
> 
> [...]

> [@DetlevD](#):
>
> This is botch.
> 
> You are about to run into the wild.  
> If you remove the filetype extension, then the files probably become invalid.  
> See post #3 in this thread, where I told you to modify the filename, but not the extension.

The code itself my be botch, the approach is proper

As I do not want to risk of changing a strange [but correct] title, I need to process end of filename with extension at the same time

Today I'm using WAV, FLAC, MP3, WV; but tomorrow I may be using dome two other formats, that from their repeated extension will create even more possibilities for such valid titles. And thus I should process end + extension and not just the end

What I was trying to achieve with this code was:  
1] look at the end of file and extension  
2] see if any number of ".flac" there is  
3] delete every ".flac" and place just one ".flac" at the end of filename + extension  
This would not change the extension. In 99.99% cases it would just replace ".flac" with ".flac" in the extension and do nothing in the filename

---

<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:** [April 22, 2016, 8:09am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/13 "2016-04-22T08:09:23Z")

</div>

> [@zerow](#):
>
> The code itself my be botch, the approach is ... What I was trying to achieve with this code was:  
> 1] look at the end of file and extension  
> 2] see if any number of ".flac" there is  
> 3] delete every ".flac" and place just one ".flac" at the end of filename + extension ...

Note: The dot in your regular expression denotes any character.

DD.20160422.1209.CEST

---

<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:** [April 26, 2016, 4:25pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/14 "2016-04-26T16:25:30Z")

</div>

> [@zerow](#):
>
> What I was trying to achieve [...] was:  
> 1] look at the end of file and extension  
> 2] see if any number of ".flac" there is  
> 3] delete every ".flac" and place just one ".flac" at the end of filename + extension  
> [...]

A now, for a simple solution

Here is what works for "Field" "\_FILENAME" in "Replace with regular expression"  
[when "Replace matches" is set to ".flac"]

```
flac.flacThis turns "flac.flac" into a single ".flac"

```

And here is what doesn't work

```
$Right(flac.flac)
$cutRight(flac.flac)
$trimRight(flac.flac)

```

So how do I tell it to make the replacement just at the end?

---

<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:** [April 27, 2016, 3:12am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/15 "2016-04-27T03:12:16Z")

</div>

> [@zerow](#):
>
> ... And here is what doesn't work ...

Try out the examples from there ... post #3 in this thread ...  
[flac.flac / mp3.mp3](https://community.mp3tag.de/t/17860/3)

DD.20160427.0712.CEST

---

<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, 2016, 7:33pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/16 "2016-05-04T19:33:14Z")

</div>

> [@DetlevD](#):
>
> Try out the examples from there ... post #3 in this thread ...  
> [flac.flac / mp3.mp3](https://community.mp3tag.de/t/17860/3)

> [@DetlevD](#):
>
> **\_FILENAME \<== $replace(%\_filename%'$',' '%\_extension%'$',)**

This does the trick

But only if there is a pause

So it works for  
**xxx flac.flac**  
but does not for  
**xxxflac.flac**  
because it just adds a dollar sign

> [@DetlevD](#):
>
> **\_FILENAME \<== $trimRight($replace(%\_filename%'$',%\_extension%'$',))**

This does the trick even where this is not pause

But not when there is more than one repetition

So it works for  
xxx flac.flac  
**xxxflac.flac**  
but does not for  
**xxxflacflac.flac  
xxxflac.flac.flac**  
because it just adds a dollar sign

So as long as I combine these both with a foolow up of cutting of  
**flac$  
mp3$  
wav$  
wv$  
wav$**  
I should be able to do that [rare] work on formats that I work with, without [very rarely] accidentally messing up strange both valid [original] titles

Thank you for all the info

---

<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:** [May 5, 2016, 6:05am UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/17 "2016-05-05T06:05:20Z")

</div>

> [@zerow](#):
>
> This does the trick ...

As I said already, you should concentrate your effort to check your code routines from before, because there is the coding quirk, which creates multiple strings of the file extension at the end of the filename.

See once again ... [flac.flac / mp3.mp3](https://community.mp3tag.de/t/17860/3)  
... I have added a fourth example formatstring.

DD.20160505.1004.CEST, DD.20160505.1659.CEST

---

<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 9, 2016, 3:26pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/18 "2016-05-09T15:26:24Z")

</div>

> [@DetlevD](#):
>
> [...]  
> See once again ... [flac.flac / mp3.mp3](https://community.mp3tag.de/t/17860/3)  
> ... I have added a fourth example formatstring.  
> [...]

Thank you for all the info

---

<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:26pm UTC](https://community.mp3tag.de/t/flac-flac-mp3-mp3/17860/19 "2026-02-09T12:26:12Z")

</div>

Closed on February 9, 2026, 12:26pm UTC


