# conditional logic in FILENAME -\> TAG

**URL:** https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442
**Category:** Support
**Created:** [August 25, 2011, 4:59pm UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442 "2011-08-25T16:59:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ltwally](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/df788c/32.png) [@ltwally](https://community.mp3tag.de/u/ltwally)
#### Post date: [August 25, 2011, 4:59pm UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/1 "2011-08-25T16:59:19Z")

</div>

I mostly use MP3TAG to fix the ID3 fields in concert bootlegs. All too often I run across files with the song-title and comments in the filename, but empty in the ID3 tags.

Here are three examples:

> 01. When You're On Top.mp3 02. Three Marlenas (fast version).mp3 03. 6th Avenue Heartache [laid back version].mp3

Right now, I have multiple FILENAME -\> TAG setups, and I have to sift through the files to select the right ones for the right operators.

I'm rather lazy, however, and would really like to set up some conditional logic in my FILENAME -\> TAG rule that would gracefully handle multiple scenarios.

Some pseudo-code of what I'm looking for:

```
%track%. %title% IF_STRING_MATCH="(%string%)" THEN="(%comment%)" ELSEIF="[%string%]" THEN="[%comment%]"

```

Does anyone know how to do this?

Thanks in advance.

---

<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: [August 26, 2011, 3:03am UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/2 "2011-08-26T03:03:51Z")

</div>

You can include a comparison in the converter e.g. like this:

$num(%track%,3) - $if($eql(%artist%,%composer%),%bpm%,%language%) \_ %title%

Fill in the gaps.

---

<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: [August 26, 2011, 5:37am UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/3 "2011-08-26T05:37:06Z")

</div>

> [@ohrenkino](#):
>
> You can include a comparison in the converter e.g. like this: ...

Hmm, is this really possible to write a scripting language expession into the Formatstring edit field of the converter "Filename- Tag"?  
Wouldn't it be better to use an action "Guess values" to solve the OP's request?

DD.20110826.0938.CEST

---

<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: [August 26, 2011, 6:29am UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/4 "2011-08-26T06:29:06Z")

</div>

> [@DetlevD](#):
>
> Hmm, is this really possible to write a scripting language expession into the Formatstring edit field of the converter "Filename- Tag"?

Well ... the preview shows a string that matches the expected outcome ... and even modifies it according to a modified expression.

What I still can't do is the if .. then ... else.  
As I am always rather reluctant to trust my abilities to define matching patterns (usually there is an important exception to the rule), I prefer filters to limit the amount of treated files... like this I would eliminate nested conditions. But then again: if you filter you wouldn't need the if-conditions anyway.

---

<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: [August 26, 2011, 6:48am UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/5 "2011-08-26T06:48:33Z")

</div>

> [@ohrenkino](#):
>
> Well ... the preview shows a string that matches the expected outcome ... and even modifies it according to a modified expression. ...

Please check again ... the talk is of the converter "Filename - Tag [Alt]+[2]"

> [@ohrenkino](#):
>
> ...  
> What I still can't do is the if .. then ... else.  
> As I am always rather reluctant to trust my abilities to define matching patterns (usually there is an important exception to the rule), I prefer filters to limit the amount of treated files... like this I would eliminate nested conditions. But then again: if you filter you wouldn't need the if-conditions anyway.

Yes, Mp3tag often offers different methods to reach the goal.  
Hence I suggested to use the action "guess values".  
In the "Source format" edit field one can apply a scripting expression, for example a $regexp function, to catch all three cases from post #1 at once, at least handle the cases with round and square brackets at once.

DD.20110826.1050.CEST

---

<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: [August 26, 2011, 7:02am UTC](https://community.mp3tag.de/t/conditional-logic-in-filename-tag/12442/6 "2011-08-26T07:02:33Z")

</div>

> [@DetlevD](#):
>
> Please check again ... the talk is of the converter "Filename - Tag [Alt]+[2]"

Apparently the dose of morning coffee had not yet reached its destination. You are right.

---

<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/conditional-logic-in-filename-tag/12442/7 "2026-02-09T12:23:18Z")

</div>


