# Conditional Formatting Tag - Filename

**URL:** https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703
**Category:** Support
**Created:** [May 8, 2013, 6:38am UTC](https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703 "2013-05-08T06:38:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)
#### Post date: [May 8, 2013, 6:38am UTC](https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703/1 "2013-05-08T06:38:13Z")

</div>

I use MP3TAG to move content into the library to a consistent structure.  
I am building 1 action to 'rule them all', so any and all content is moved into the library in a consistent way.

I like to store artists with 'The ' in front with ', The' in the back  
W:\Music\Artist, The...  
Discnumbers 1 or 1\X - i want to add to end of album Folder path (CD1) and ideally have the Albumname as root.  
W:\Music\Artist(Year) Album with two discs  
W:\Music\Artist(Year) Album with two discs\Album with two disc (CD1)\tracks  
W:\Music\Artist(Year) Album with two discs\Album with two disc (CD2)\tracks  
(i'll need to handle various use cases of no disc number, discnumber alone, discnumber\totaldiscs.)

using some advice on here on regular expressions i added a conditional option to the tag to filename function, for the artist bit.

W:\Music$IF($eql($left(%albumartist%,4),The ),$regexp(%albumartist%,^The (.+),'$1, The'),%albumartist%)(%year%) %album%$num(%track%,2). %title%

however it turns out that $regexp has a conditional characteristic. This also works

W:\Music$regexp(%albumartist%,^The (.+),'$1, The')(%year%) %album%$num(%track%,2). %title%

but i guess $regexp can only offer conditional logic on the characters in expression. When i build this out for 'Discnumbers in path / (CD1)' ill need to use the $IF function again...

has anyone done this already or got their own single action that formats all content into paths to a set criteria based on such matters as the above eg discnumbers, to give me ideas on best practise/options.

thank you

---

<div class="post-metadata">

### Author: ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)
#### Post date: [May 9, 2013, 5:41am UTC](https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703/2 "2013-05-09T05:41:01Z")

</div>

W:\Music$regexp(%albumartist%,^The (.+),'$1, The')(%year%) %album%$if($nequal(%discnumber%,''),$regexp(\CD %discnumber%,(\CD 1/1)|((\CD ._)/._),$3),)$num(%track%,2). %title%

In case it helps, i borrowed some advice from the forums for above, which seems to work - test 1st.

If artist starts with 'The ' store in file system as artist, The.  
If the discnumber field is populated as X or X\Y, store Multiple discs as subfolders to the album 'CD 1', 'CD 2' etc, otherwise dont create a disk subfolder.

---

<div class="post-metadata">

### Author: ![ginjaninja](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/g/ed8c4c/32.png) [@ginjaninja](https://community.mp3tag.de/u/ginjaninja)
#### Post date: [May 9, 2013, 3:27pm UTC](https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703/3 "2013-05-09T15:27:30Z")

</div>

W:\Music$regexp(%albumartist%,^The (.+),'$1, The')(%year%) %album%$if($nequal(%discnumber%,""),(%year%) %album% CD$fmtNum(%discnumber%),)$num(%track%,2). %title%

works and is simpler

---

<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:24pm UTC](https://community.mp3tag.de/t/conditional-formatting-tag-filename/14703/4 "2026-02-09T12:24:28Z")

</div>


