# New to Picard Scripts

**URL:** https://community.metabrainz.org/t/new-to-picard-scripts/342094
**Category:** MusicBrainz Picard
**Created:** [November 16, 2017, 7:50pm UTC](https://community.metabrainz.org/t/new-to-picard-scripts/342094 "2017-11-16T19:50:59Z")
**Posts on this page:** 1
**Showing post:** 4

<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: [November 28, 2017, 9:50pm UTC](https://community.metabrainz.org/t/new-to-picard-scripts/342094/4 "2017-11-28T21:50:43Z")

</div>

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 album artist name. If the first character is not an alpha the _ **nonalpha=“#”** _ part causes it to return an octothorpe.
- _ **/%albumartist%** _ inserts a path separator to create a new subdirectory called the name of the album artist.
- _**/$left(**_ inserts a path separator to create a new subdirectory under the artist directory called “year - album name”. This subdirectory is where the music files are stored. The _**$if2(**_ causes the year to be the first one of “release date”, “original release date” found. If neither is present, the year is displayed as “0000”. The _**$left(**_ takes only the year (i.e.: the first four digits) from the date for display.
- _**$if($gt(**_ causes the track number to be prefaced by the disc number only if there are more than one disc in the album.
- _**$num(**_ causes the track number to be padded to a two-digit number (i.e.: 01, 02, etc.) which allows proper sorting of the tracks in the directory.
- _ **- %title%** _ includes the track title in the file name, separated from the track number by a hyphen.

If you wanted each disc in a separate directory the script would change slightly as:

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

```

I hope this helps move you a bit closer to what you’re wanting to accomplish. For more information about scripting in Picard, there’s [https://picard.musicbrainz.org/docs/scripting/](https://picard.musicbrainz.org/docs/scripting/) and [https://picard.musicbrainz.org/docs/tags/](https://picard.musicbrainz.org/docs/tags/).

edit:

Also, just to clarify this goes in the file naming script section of the options as:

 ![image](https://community.metabrainz.org/uploads/default/original/2X/e/eec91ca9496e3dd65817f5afc4d7d7256f9fe931.png)

---

_[View the full topic](https://community.metabrainz.org/t/new-to-picard-scripts/342094)._
