# Rename file only if extension matches (.Mp3, .Flac, etc)

**URL:** https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499
**Category:** Support
**Created:** [May 31, 2012, 6:35am UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499 "2012-05-31T06:35:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![LaurenBacall](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@LaurenBacall](https://community.mp3tag.de/u/LaurenBacall)
#### Post date: [May 31, 2012, 6:35am UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499/1 "2012-05-31T06:35:54Z")

</div>

I am in the process of setting up an Action for renaming recorded podcasts. Each podcast has two files: one lossless (FLAC) and one lossy (MP3).

I wish to rename the FLAC files differently than the MP3 files, so it's easier to differentiate between the lossless and lossy versions.

I found some RegEx on the forum that renames the files based on their creation date, but for the FLAC files I wanted to append the string '[original]' after the RegEx.

I don't personally have a knowledge of RegEx, but I do know that you can include conditional operators ('if'). Does anyone have an answer?

Eg:

MP3:  
2012.05.31.mp3

FLAC:  
2012.05.31 [original].flac

---

<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 31, 2012, 8:19am UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499/2 "2012-05-31T08:19:09Z")

</div>

> [@LaurenBacall](#):
>
> I am in the process of setting up an Action for renaming recorded podcasts. Each podcast has two files: one lossless (FLAC) and one lossy (MP3). I wish to rename the FLAC files differently than the MP3 files ... for the FLAC files I wanted to append the string '[original]' after the RegEx.  
> Eg:  
> MP3:  
> 2012.05.31.mp3  
> FLAC:  
> 2012.05.31 [original].flac

You did not show the specific Regular Expression, you did talk about, so I assume there is no RegExp involved, but only basic Mp3tag scripting features.

If you want to apply an action to append some data to an existing tag-field content, then the following proposals may help.

1. Set Filter  
"%\_extension%" IS "FLAC"

2. Use Action  
Action: Format value  
Field: \_FILENAME  
Formatstring: **%\_filename%' [original]'**

... or ...

1. Use Action  
Action: Format value  
Field: \_FILENAME  
Formatstring: **$if($eql($lower(%\_extension%),'flac'),%\_filename%' [original]',%\_filename%)**  
Because %\_extension% returns always lower cased names this should work too ...  
Formatstring: **$if($eql(%\_extension%,'flac'),%\_filename%' [original]',%\_filename%)**

See also:  
[Actions](https://community.mp3tag.de/t/967/5)

DD.20120531.1218.CEST

---

<div class="post-metadata">

### Author: ![LaurenBacall](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/35a633/32.png) [@LaurenBacall](https://community.mp3tag.de/u/LaurenBacall)
#### Post date: [May 31, 2012, 8:34am UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499/3 "2012-05-31T08:34:33Z")

</div>

> [@DetlevD](#):
>
> 1. Use Action  
> Action: Format value  
> Field: \_FILENAME  
> Formatstring: **$if($eql($lower(%\_extension%),'flac'),%\_filename%' [original]',%\_filename%)**

Thanks so much, works a treat.

As for the Regular Expression, for anyone interested, this is what I'm using:

Action: Format value

Field:  
\_FILENAME

Format string:  
~~$regexp(%\_file\_create\_date%,(..)/(..)/(....),$3.$2.$1)~~

**Edit:** the above format string fails when the Day is a single digit, the following code works instead:

$regexp(%\_file\_create\_date%,(\d\d?)/(\d\d?)/(\d\d\d\d),$3.$2.$1)

I'm working on a better solution, as using the File Creation Date timestamp is unreliable, it changes when the file is copied to a different location.

---

<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 31, 2012, 8:52am UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499/4 "2012-05-31T08:52:43Z")

</div>

> [@LaurenBacall](#):
>
> Thanks so much, works a treat.  
> As for the Regular Expression, for anyone interested, this is what I'm using:  
> Action: Format value  
> Field: \_FILENAME  
> Format string: $regexp(%\_file\_create\_date%,(..)/(..)/(....),$3.$2.$1)

See also:  
[writing file creation date to tag with this format : YYYYMMDD (year, month, day)](https://community.mp3tag.de/t/11174/2)

If you set your system's date time display according to ISO 8601, then you do not need to convert the file's creation date tíme, that means %\_file\_create\_date% will return immediately '2012-05-31'.

DD.20120531.1252.CEST

---

<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:23pm UTC](https://community.mp3tag.de/t/rename-file-only-if-extension-matches-mp3-flac-etc/13499/5 "2026-02-09T12:23:52Z")

</div>


