# Help with conditional tag \> filename

**URL:** <https://community.mp3tag.de/t/help-with-conditional-tag-filename/18186>\
**Category:** Support\
**Created:** [August 20, 2016, 1:26am UTC](https://community.mp3tag.de/t/help-with-conditional-tag-filename/18186 "2016-08-20T01:26:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lose311](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/45deac/32.png) [@lose311](https://community.mp3tag.de/u/lose311)\
**Post date:** [August 20, 2016, 1:26am UTC](https://community.mp3tag.de/t/help-with-conditional-tag-filename/18186/1 "2016-08-20T01:26:05Z")

</div>

Hey everybody. I don't know if the devs are on the forum, but you are, thank you! I have used Mp3tag for years and I really love it.

Anyway, I'm planning an overhaul of my music library, and I want to reorganize by:

```
Artist\Album [year]\Tracknum - Title

```

So I have the following for Tag\>Filename, but it's not perfect:

```
C:\music\\%artist%\\%album% '['$num(%year%,4)']'\[$num(%track%,2) -]%title%

```

The problem is, for for the Year field I sometimes have text, like 'Misc' and sometimes it's empty. So how can I use $num(%year%,4) when it's a number, just surround it with '[]' when it's text, and leave empty when there isn't any year data at all? I tried using '$if()' but couldn't get the logic right.

So all three of these would be possible:

```
C:\music\Artist\Album [1999]\01 - Track
C:\music\Artist\Album [Misc]\01 - Track
C:\music\Artist\Album\01 - Track

```

(And sometimes there's no track numbers, but I think I have that part figured out) I could probably do it with regex, but wanted to know if there is a better way. Can you just do $if(%year%, ..., ...) so IF there is year data, THEN ....

Thanks!

---

<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 20, 2016, 6:48am UTC](https://community.mp3tag.de/t/help-with-conditional-tag-filename/18186/2 "2016-08-20T06:48:37Z")

</div>

Wouldn't it be much easier to filter for those files that have a decent number in YEAR, rename them and then filter for the files that don't and rename them then instead of fiddling a longish $if() statement?  
Perhaps something like:  
'['$ifgreater($div(%year%,10),10,$num(%year%,4),%year%)']'

---

<div class="post-metadata">

**Author:** ![lose311](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/45deac/32.png) [@lose311](https://community.mp3tag.de/u/lose311)\
**Post date:** [August 20, 2016, 7:09pm UTC](https://community.mp3tag.de/t/help-with-conditional-tag-filename/18186/3 "2016-08-20T19:09:13Z")

</div>

Wow, I can't believe that didn't occur to me. Thanks, I'll give it a try.

---

<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/help-with-conditional-tag-filename/18186/4 "2026-02-09T12:26:23Z")

</div>

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


