# Need help with sorting

**URL:** https://community.metabrainz.org/t/need-help-with-sorting/350329
**Category:** MusicBrainz Picard
**Created:** [January 3, 2018, 11:22am UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329 "2018-01-03T11:22:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![giggalo](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@giggalo](https://community.metabrainz.org/u/giggalo)
#### Post date: [January 3, 2018, 11:22am UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329/1 "2018-01-03T11:22:29Z")

</div>

Tried for 2 months and read everything and just can’t get it to do what I want

1. When the files load up and I save them it does not put all the files in the same folder, it makes other folders. I would like for all the files that show to be complete albums to be put in 1 single folder with all the tracks.

2. When saving I would like it to make the folder artist name reversed like  
The Beatles to be  
Beatles, The or  
Beatles - The

3. When saving them like The Beatles , it makes a folder B and puts the Beatles in the B folder

4. When saving the files that have more than 1 cd make folders for the other cds, like CD1 CD2 and so on.

---

<div class="post-metadata">

### Author: ![rdswift](https://community.metabrainz.org/user_avatar/community.metabrainz.org/rdswift/32/7032_2.png) [@rdswift](https://community.metabrainz.org/u/rdswift)
#### Post date: [January 3, 2018, 4:32pm UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329/2 "2018-01-03T16:32:45Z")

</div>

Most of this is covered in my response at:

> [@New to Picard Scripts](https://community.metabrainz.org/t/new-to-picard-scripts/342094/4):
>
> Give this a try. It might not be exactly what you’re looking for but I think it should be close. $upper($firstalphachar(%albumartistsort%,nonalpha="#"))/%albumartist%/$left($if2(%date%,%originaldate%,0000),4) - %album%/$if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) - %title% The steps taken in the script are: $upper( makes the alphabetical directory upper case. $firstalphachar( returns the first alpha character of the text provided - in this case the sorted version of the al…

I suggest you try the following naming script and see if that does what you require:

```
%albumartistsort%/%album%/$if($gt(%totaldiscs%,1),CD%discnumber%/,)$num(%tracknumber%2) - %title%

```

If I’ve misunderstood what you’re looking for in terms of format, please let me know.

---

<div class="post-metadata">

### Author: ![giggalo](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@giggalo](https://community.metabrainz.org/u/giggalo)
#### Post date: [January 3, 2018, 8:48pm UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329/3 "2018-01-03T20:48:54Z")

</div>

rdswift it did exactly what I needed it to do, thank you so much.  
After reading and your explanation on the commands for what each of them do makes it simple to understand, the only command I can not find in the scripting page is how to format the Artist Name like (The Beatles) to move The to the end of the name like

Beatles, The  
or  
Beatles - The

This would only be for the folder name of the Artist when it moves the files to the new folder B

What command would it use and where would it be placed in here

$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/%albumartist%/$left($if2(%date%,%originaldate%,0000),4) - %album%/$if($gt(%totaldiscs%,1),Disc %discnumber%/,)$num(%tracknumber%,2) - %title%

Thanks for all your help

---

<div class="post-metadata">

### Author: ![rdswift](https://community.metabrainz.org/user_avatar/community.metabrainz.org/rdswift/32/7032_2.png) [@rdswift](https://community.metabrainz.org/u/rdswift)
#### Post date: [January 3, 2018, 8:53pm UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329/4 "2018-01-03T20:53:51Z")

</div>

All you would need to do is change %albumartist% to %albumartistsort%. The resulting command would be:

```
$upper($firstalphachar(%albumartistsort%,nonalpha="#"))/%albumartistsort%$left($if2(%date%,%originaldate%,0000),4) - %album%/$if($gt(%totaldiscs%,1),Disc %discnumber%/,)$num(%tracknumber%,2) - %title%

```

Hope I understood you correctly and this helps.

---

<div class="post-metadata">

### Author: ![giggalo](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@giggalo](https://community.metabrainz.org/u/giggalo)
#### Post date: [January 3, 2018, 10:48pm UTC](https://community.metabrainz.org/t/need-help-with-sorting/350329/5 "2018-01-03T22:48:05Z")

</div>

That did the trick, thanks for your help
