# Need help with IF function script

**URL:** https://community.mp3tag.de/t/need-help-with-if-function-script/5624
**Category:** Support
**Created:** [October 21, 2007, 5:43am UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624 "2007-10-21T05:43:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![TheChipstar](https://community.mp3tag.de/user_avatar/community.mp3tag.de/thechipstar/32/200_2.png) [@TheChipstar](https://community.mp3tag.de/u/TheChipstar)
#### Post date: [October 21, 2007, 5:43am UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624/1 "2007-10-21T05:43:33Z")

</div>

I am wanting to help iTunes sort properly.

At the moment (default sorting) iTunes sorts like this:  
If Artist name starts with either "A" or "The" (are there more? I only know of these two) iTunes ignores these.  
Example

- "A Perfect Circle" doesn't get sorted to 'A' but instead to 'P'
- "The Beatles" doesn't get sorted to 'T' but instead to 'B'

Now I like how iTunes sorts the artists that contain "The" but not "A".  
I would like "A Perfect Circle" to be sorted to 'A', but "The Beatles" to be sorted to 'B'.

Now this involves using the tag field PERFORMERSORTORDER.  
But I also need an IF function to help me out.  
It would search the %artist% field for "The" (which will always be Mixed caps ie not: the, tHe, thE, THe, tHE, ThE, THE; and will always be the first three letters if the %artist% string was to contain one; but not neccessarily the only "The" within the string though).  
If the function found a "The" then it would use the %artist% string value, minus the "The", as the value in the PERFORMERSORTORDER tag ("The Beatles" becomes "Beatles"). If it didn't find "The" than it would just use the %artist% string value as it is ("A Perfect Circle" stays as "A Perfect Circle").

Make any sence?

Any help would be much appreciated!

---

<div class="post-metadata">

### Author: ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)
#### Post date: [October 21, 2007, 8:53am UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624/2 "2007-10-21T08:53:41Z")

</div>

Just copy everything to performersortorder and then use this kind of action to the "The "  
[Actions](https://community.mp3tag.de/t/967/1)

---

<div class="post-metadata">

### Author: ![TheChipstar](https://community.mp3tag.de/user_avatar/community.mp3tag.de/thechipstar/32/200_2.png) [@TheChipstar](https://community.mp3tag.de/u/TheChipstar)
#### Post date: [October 21, 2007, 6:38pm UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624/3 "2007-10-21T18:38:04Z")

</div>

A lot simpler than I thought...

Thanks a lot for that!

---

<div class="post-metadata">

### Author: ![vkostas](https://community.mp3tag.de/user_avatar/community.mp3tag.de/vkostas/32/227_2.png) [@vkostas](https://community.mp3tag.de/u/vkostas)
#### Post date: [May 18, 2008, 7:21pm UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624/4 "2008-05-18T19:21:20Z")

</div>

> [@dano](#):
>
> Just copy everything to performersortorder and then use this kind of action to the "The "  
> [Actions](https://community.mp3tag.de/t/967/1)

Hi Dano,

I want to create an action group to format sorting tags after being filled from normal tag. Starting "The ", "A " etc should be moved to the end of the (sort) tag. E.g. The Beatles -\> Beatles, The  
There are several SORT tags that need this conversion (album, Artist, Title).

1. Is it possible to add in the same regular expression several patterns?

$regexp(%artistsortorder%,^The (.+),$1',' The)

$regexp(%artistsortorder%,^A (.+),$1',' A) etc.  
Maybe using pipeline character could be feasible but I haven't realized yet.

 
1. Since the same set of process should be used for several tags is there any way to make it dynamic?

 

Thank you,  
Victor

---

<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:20pm UTC](https://community.mp3tag.de/t/need-help-with-if-function-script/5624/5 "2026-02-09T12:20:33Z")

</div>


