# Repository for neat file name string patterns and tagger script snippets

**URL:** https://community.metabrainz.org/t/repository-for-neat-file-name-string-patterns-and-tagger-script-snippets/2786
**Category:** MusicBrainz Picard
**Tags:** filenaming, examples, taggerscript, picard
**Created:** [March 11, 2016, 1:16am UTC](https://community.metabrainz.org/t/repository-for-neat-file-name-string-patterns-and-tagger-script-snippets/2786 "2016-03-11T01:16:46Z")
**Posts on this page:** 1
**Showing post:** 73

<div class="post-metadata">

### Author: ![Billy\_Yank](https://community.metabrainz.org/user_avatar/community.metabrainz.org/billy_yank/32/1585_2.png) [@Billy\_Yank](https://community.metabrainz.org/u/Billy_Yank)
#### Post date: [November 11, 2019, 6:14am UTC](https://community.metabrainz.org/t/repository-for-neat-file-name-string-patterns-and-tagger-script-snippets/2786/73 "2019-11-11T06:14:54Z")

</div>

EDIT: I found a serious misplaced parenthesis error in my script. It was causing soundtracks to become completely messed up. I’ve replaced it below with my corrected version.

I rewrote my script to make it a little more compact. I used to have a lot of repeated code, but now I pulled the common code out of the $if statements and consolidated it.

I also added a feature I just discovered to clean up my folder names. I added some scripts to set control variables and then my naming script adds some disambiguating elements to file names only where necessary.

I have a couple versions of the same release, and I was using release comments to keep them in separate folders. The unfortunate side effect of this was presence of release comments on releases where I didn’t need them. Now I can designate only certain releases to add the release comment to the folder name, while all the rest are unaffected. Since variables are written to the files as tags, I only have to designate the release once, and it will always use the alternate naming script.

In this test, you can see the AKB48 single has it’s release comments (Type-A, Type-B) in the folder name, while the Rush album doesn’t. Kate Bush’s Cloudbusting single now has it’s media type in the folder name, but none of the other albums do.

 ![image](https://community.metabrainz.org/uploads/default/original/3X/f/3/f3cda33030d8082a6595fc5e8ce54563b1d19db2.png)

In the Scripting tag, I added the following lines, each in it’s own script:

```auto
$set(usereleasecomment,1)
$set(usemediatype,1)
$delete(usereleasecomment)
$delete(usemediatype)

```

I also have a common script that’s set to run automatically.

```auto
$if($gt(%_totalalbumtracks%,99),$set(tracknumber,$num(%tracknumber%,3)),$set(tracknumber,$num(%tracknumber%,2)))

```

My full naming script is:

```auto
$replace(
$replace(
$replace(
$replace(
$replace(
$replace(
$if($in(%releasetype%,soundtrack),
	$noop(Soundtracks)
	Soundtrack/~
	$left($swapprefix(%album%,A,An,The),1)~/$swapprefix(%album%,A,An,The),
		$if(%compilation%,
		$noop(Various artist albums)
		Various Artists/~
		$left($swapprefix(%album%,A,An,The),1)~/$swapprefix(%album%,A,An,The),
		$noop(Normal albums)
		~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/
		$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%))
	$noop(Common path)
	$if(%usereleasecomment%,$if(%_releasecomment%, \(%_releasecomment%\)))
	$if(%usemediatype%,$if(%media%, \(%media%\)))
	$if($in(%releasetype%,single), \(Single\))
	$if($in(%releasetype%,ep), \(EP\))/
	$if($gt(%totaldiscs%,1),%discnumber%)
	$if($gt(%_totalalbumtracks%,99),$num(%tracknumber%,3),$num(%tracknumber%,2)) - %artist% - %title%
,*,[x])
,?,)
,:,-)
,",')
,<,{)
,>,})

```

---

_[View the full topic](https://community.metabrainz.org/t/repository-for-neat-file-name-string-patterns-and-tagger-script-snippets/2786)._
