# Directory & Filename Scripting

**URL:** <https://community.metabrainz.org/t/directory-filename-scripting/531055>\
**Category:** MusicBrainz Picard\
**Tags:** scripting\
**Created:** [April 28, 2021, 8:46pm UTC](https://community.metabrainz.org/t/directory-filename-scripting/531055 "2021-04-28T20:46:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregdreelin](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/g/47e85d/32.png) [@gregdreelin](https://community.metabrainz.org/u/gregdreelin)\
**Post date:** [April 28, 2021, 8:46pm UTC](https://community.metabrainz.org/t/directory-filename-scripting/531055/1 "2021-04-28T20:46:15Z")

</div>

I am very new to Picard and I have searching around for the right way to setup the scripts to save and organize all the files into the below:

Artist  
Album Name (Year)  
Artist - Song Title - Track# 01.mp3

Artist  
Album Name (Year)  
CD 1  
Artist - Song Title - Track# 01.mp3  
CD 2  
Artist - Song Title - Track# 01.mp3

A couple of people posted the below but the Track# is at the end.

%albumartist%/%album%/$if($gt($if2(%totaldiscs%,1),1),$if2(%discnumber%,1)-,)$num($if2(%tracknumber%,1),2) %title%

---

<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:** [April 28, 2021, 9:25pm UTC](https://community.metabrainz.org/t/directory-filename-scripting/531055/2 "2021-04-28T21:25:48Z")

</div>

Welcome to the growing list of Picard users. I suggest that you take a look at the [file naming script tutorial](https://picard-docs.musicbrainz.org/en/tutorials/naming_script.html), which should help you understand how to make small edits to the file naming script. If I understand you correctly, I think that your needs can be met with the following script:

```auto
%albumartist%/%album% \($if(%date%,$left(%date%,4),0000)\)/$if($gt($if2(%totaldiscs%,1),1),CD $if2(%discnumber%,1)/,)%artist% - %title% - Track $num($if2(%tracknumber%,1),2)

```

---

<div class="post-metadata">

**Author:** ![gregdreelin](https://community.metabrainz.org/letter_avatar_proxy/v4/letter/g/47e85d/32.png) [@gregdreelin](https://community.metabrainz.org/u/gregdreelin)\
**Post date:** [April 28, 2021, 9:53pm UTC](https://community.metabrainz.org/t/directory-filename-scripting/531055/3 "2021-04-28T21:53:13Z")

</div>

Ok thanks I just wanted a second pair of eyes on it.
