Re: Repository for cool file naming parameter strings

I've used the scripts posted here as inspiration and come up with a couple of simple scripts to organize my collection.

Single artist script:

~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%/%artist% - $num(%tracknumber%,2) - %title%

This sorts by the artist's sortname and names the file in the pattern "artist - track - title".

For example:
D:\Music CDs\~D~\Dylan, Bob\Blood on the Tracks\Bob Dylan - 04 - Idiot Wind.mp3


Various artist script:

$if($eq(%albumartist%,Various Artists),$if2(%albumartist%,%artist%)/~$left(%album%,1)~/%album%/$num(%tracknumber%,2) - %artist% - %title%,~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%/$num(%tracknumber%,2) - %artist% - %title%)

If the album artist name is "Various Artists", this puts the album in a folder called "Various Artists", then sorts by album name and names the file in the pattern "track - artist - title".

For example:
D:\Music CDs\Various Artists\~B~\Bloodshot Records Label Sampler\03 - Exene Cervenka - The Willow Tree.mp3

If the album artist name is anything else, this sorts the album like a single artist album, but with a filename patern like the the various artists' albums.

For example:
D:\Music CDs\~M~\Murdoch, Alexi\Away We Go\05 - The Stranglers - Golden Brown.mp3

If you're on a Unix OS, you'll need to replace the ~ with something else.  I just use them because I like the way they look.

"I say we invite opportunity inside for a nice cup of tea, then hit her on the head and steal her purse." - Kevyn Andreyasn
- Schlock Mercenary by Howard Tayler

Re: Repository for cool file naming parameter strings

Mine's rather long to include here, but it uses lots of various tricks to really narrow down and control my large collection.  It's in the wiki: http://wiki.musicbrainz.org/User:BrianF … ing_String

You stumble onto 50 berserkers!

Re: Repository for cool file naming parameter strings

UllicPendragon wrote:

No need for a new thread. It works perfectly! Thanks ever so much for your help, oc! Much appreciated!

My apologies for derailing the thread with my troubleshooting queries. In the interest of getting back on the right track, I'll post my final code in case anyone is curious and would like to use it and/or customise it for their own purposes:

Single Artist File Naming Format

$replace($if($eq($left($if2(%albumartist%,%artist%),4),The ),[-=$left($right($if2(%albumartist%,%artist%),$sub($len($if2(%albumartist%,%artist%)),4)),1)=-],[-=$left($if2(%albumartist%,%artist%),1)=-])/$rreplace($replace($if2(%albumartist%,%artist%),...,…),\\.\$,$noop(.))/$if(%date%,[$left(%date%,4)] )$rreplace($replace(%album%,...,…),\\.\$,$noop(.))/$num(%tracknumber%,2) - $replace(%title%,...,…),_,$noop(.))

So... What does it do?
1. All files will be placed into this folder structure:
[-=First Letter of ArtistName=-]\ArtistName\[Year] AlbumName\TrackNumber - TrackName
2. The [Year] portion will be omitted from the AlbumName if there is no release date
3. If the ArtistName starts with "The ", it will take this into account when determining the [-=First Letter of ArtistName=-]
4. If the ArtistName, AlbumName or TrackName contain a three-dot "..." sequence, it will be replaced with a true ellipsis "…"
5. If the ArtistName or AlbumName ends in a dot "." then that dot will be removed
6. Finally, any and all underscores "_" will be removed from the entire path

Example #1: ArtistName Ends in Dot "."
Sixx:A.M. > The Heroin Diaries > Life is Beautiful
[-=S=-]\SixxA.M\[2007] The Heroin Diaries Soundtrack\03 - Life Is Beautiful.mp3

Example #2: AlbumName, TrackName Contain Three-Dot "..." Sequence
Metallica > ...And Justice For All > ...And Justice For All
[-=M=-]\Metallica\[1988] …and Justice for All\02 - …and Justice for All.mp3

Example #3: ArtistName Begins With "The "
The Fabulous Thunderbirds > Hot Stuff > Powerful Stuff
[-=F=-]\The Fabulous Thunderbirds\[1992] Hot Stuff The Greatest Hits\08 - Powerful Stuff.mp3

Multiple Artist File Naming Format

$replace($if($eq(%albumartist%,Various Artists),[~Various Artists~]/,$if($eq($left($if2(%albumartist%,%artist%),4),The ),[-=$left($right($if2(%albumartist%,%artist%),$sub($len($if2(%albumartist%,%artist%)),4)),1)=-],[-=$left($if2(%albumartist%,%artist%),1)=-])/$rreplace($replace($if2(%albumartist%,%artist%),...,…),\\.\$,$noop(.))/$if($ne(%albumartist%,Various Artists),$if(%date%,[$left(%date%,4)] )))$rreplace($replace(%album%,...,…),\\.\$,$noop(.))/$num(%tracknumber%,2) - $replace(%artist% - %title%,...,…),_,$noop(.))

So... What does it do?
1. Multi-artist albums attributed to "Various Artists" will have files placed into this folder structure:
[~Various Artists~]\AlbumName\TrackNumber - ArtistName - TrackName
2. Multi-artist albums attributed to a specific artist will have files placed into this folder structure:
[-=First Letter of AlbumArtistName=-]\AlbumArtistName\[Year] AlbumName\TrackNumber - ArtistName - TrackName
3. See Rules 2-6 for Single Artist Format above.

Example #1: Multi-Artist Album Attributed to Various Artists
Various Artists > Transformers Soundtrack > Mute Math > Transformers Theme
[~Various Artists~]\Transformers The Album\12 - Mute Math - Transformers Theme.mp3

Example #2: Multi-Artist Album Attributed to Specific Artist, ArtistName Begins With "The "
The Crystal Method > Community Service > Evil Nine > Cake Hole
[-=C=-]\The Crystal Method\[2002] Community Service\02 - Evil Nine - Cake Hole.mp3

Example #3: Multi-Artist Album Attributed to Specific Artist, AlbumName Ends in Dot "."
Yoko Kanno > Ghost in the Shell: Stand Alone Complex Original Soundtrack > Origa > Inner Universe
[-=Y=-]\Yoko Kanno\[2003] Ghost in the Shell Stand Alone Complex O.S.T\11 - ORIGA - Inner Universe.mp3


I hope people can use this or are at least inspired by this to contribute their own customised code. Again, thanks for your help, outsidecontext.

I have use this renaming script since I started redoing my collection with MB. I like how it works thank-you UllicPendragon.

I just updated Picard to 0.15.0 beta1 for NGS support. With the new way of tagging multiple disc releases, discs 1, 2, 3 etc all end up in one folder. I like using disc number tags & album subtitle tags in the metadata and works great in foobar2000 but I would like to have each disc in its own folder for file system organization. I can't understand these scripts well enough to start playing with them. I am wondering now that album tags are the same across multiple disc releases can this renaming script be changed to use disc number tags to still place each disc of a multi disc release in its own folder. If yes anyone willing to help me do that?

Re: Repository for cool file naming parameter strings

This is not working:

$if2(%albumartist%,%artist%) - %date% - %album% $if($gte(%TOTALDISCS%,2),[CD %discnumber%])/$num(%tracknumber%,2) %title%

If there is more than 1 CD, append to the folder CD 1, CD 2 ....

Thank you.

55 (edited by HumHumXX 2011-07-25 14:36:52)

Re: Repository for cool file naming parameter strings

@Tanchistu

Replace %discnumber% with %totaldiscs%.

EDIT: That actually works, but it's certainly not what you wanted, haha.

Re: Repository for cool file naming parameter strings

I've made some changes to my scripts since NGS and Picard 0.15 were released

Single Artist:

$replace(
$replace(
$replace(
$replace(
~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%$if(%_releasecomment%, \(%_releasecomment%\),$noop())$if($gt(%totaldiscs%,1),/\(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/%artist% - $num(%tracknumber%,2) - %title%
,*,[x])
,?,)
,:,-)
,",')

Multiple Artist:

$replace(
$replace(
$replace(
$replace(
$if($eq(%albumartist%,Various Artists),$if2(%albumartist%,%artist%)/~$left(%album%,1)~/%album%$if(%_releasecomment%, \(%_releasecomment%\),$noop())$if($gt(%totaldiscs%,1),/\(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/$num(%tracknumber%,2) - %artist% - %title%,~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%/$num(%tracknumber%,2) - %artist% - %title%)
,*,[x])
,?,)
,:,-)
,",')

For most releases, this ends up the same as my previous script:

Single artist:
D:\Music CDs\~D~\Dylan, Bob\Blood on the Tracks\Bob Dylan - 04 - Idiot Wind.mp3

Various artists:
D:\Music CDs\Various Artists\~B~\Bloodshot Records Label Sampler\03 - Exene Cervenka - The Willow Tree.mp3

Multiple artists:
D:\Music CDs\~M~\Murdoch, Alexi\Away We Go\05 - The Stranglers - Golden Brown.mp3

Now I've added logic to handle multi-disc releases by putting the discs in separate directories under the album name:
D:\Music CDs\~B~\Beatles, The\The Beatles\(disc 1)\The Beatles - 03 - Glass Onion.mp3

Also, if there's a release comment, that gets appended to the album name in parenthesis:
D:\Music CDs\~U~\UVERworld\CORE PRIDE (Anime Edition)\UVERworld - 01 - CORE PRIDE.mp3

"I say we invite opportunity inside for a nice cup of tea, then hit her on the head and steal her purse." - Kevyn Andreyasn
- Schlock Mercenary by Howard Tayler

57 (edited by HumHumXX 2011-08-30 12:30:51)

Re: Repository for cool file naming parameter strings

It's certainly not "cool" or anything, but it fits my needs – and heavily borrows or bluntly steals from other strings posted in this thread:

$if($eq(%_extension%,flac),Lossless,Lossy)/$if2(%albumartist%,%artist%)/$if($eq(%album%,[non-album tracks]),%album%/%title%,[$if2(%releasetype%,-)\, $if2(%releasestatus%,-)\, $if2($left(%originaldate%,4),-)] $if($gt($len(%album%),50),$left(%album%,30)[...]$right(%album%,15),%album%) $if($or(%media%,%date%),[$if2(%media%,-)\, $if2($left(%date%,4),-)],)/$if($gt(%totaldiscs%,1),$num(%discnumber%,2)-,)$num(%tracknumber%,2). $if($gt($len(%title%),50),$left(%title%,30)[...]$right(%title%,15),%title%))

+

$set(originaldate,%_originaldate%)
$if($eq(%totaldiscs%,1),$unset(totaldiscs) $unset(discnumber))

(The only difference in the VA string is that it adds %artist% to the file name.)

Result:

...\Lossless\The Velvet Underground\[album, official, 1967] The Velvet Underground & Nico [CD, 1996]\01. Sunday Morning.flac

or

...\Lossy\Ludwig van Beethoven\[compilation, official, -] Beethoven_ Piano Sonatas (feat[...]imir Ashkenazy)\01. Sonata No. 14, Op. 27 No. 2 _M[...]dagio sostenuto.ogg

Re: Repository for cool file naming parameter strings

Hi all,

Iḿ making my first steps with Picard, however this naming scripting is a little too much for me atm. Could someone please help me setup a simple naming script that will fit to my current setup ??

Current setup in mp3tag:
Normal: %artist% - $num(%track%,2) - %title%
Various: VA - $num(%track%,2) - %artist% - %title%
Result iḿ after:
Normal: /house of pain - 1992 - fine malt lyrics / House of Pain - 02 - Jump Around
Various: /VA - 1992 - somealbum / VA - 01 - someartist - trackname

I would greatly appriciate someone helping me out here..

Thanks
kamaradski

Re: Repository for cool file naming parameter strings

^ I would like exactly what Kam is after, perhaps with a master artis folder above:
HOUSE OF PAIN/house of pain - 1992 - fine malt lyrics / House of Pain - 02 - Jump Around

Thanks TT

Re: Repository for cool file naming parameter strings

@kamaradski:
$if($eq(%albumartist%,Various Artists),VA,$lower($if2(%albumartist%,%artist%))) -$if(%date%, $left(%date%,4) -) $lower(%album%)/$if($eq(%albumartist%,Various Artists),VA,%artist%) - $if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) -$if($eq(%albumartist%,Various Artists), %artist% -) %title%
@tigertales:
$upper($if($eq(%albumartist%,Various Artists),VA,$if2(%albumartist%,%artist%)))/$if($eq(%albumartist%,Various Artists),VA,$lower($if2(%albumartist%,%artist%))) -$if(%date%, $left(%date%,4) -) $lower(%album%)/$if($eq(%albumartist%,Various Artists),VA,%artist%) - $if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) -$if($eq(%albumartist%,Various Artists), %artist% -) %title%

Re: Repository for cool file naming parameter strings

SSS, (Thought I said thankyou previously, but obviously not).

I'm trying to implement this to rename and move the files; but (using Mac OS7.3) as soon as I tick 'Preferences' ... 'Moving Files' ...'Browse' it causes MB to crash/freeze (folder window pops up for half a second, then I have to do a force quit). 

Is moving files in the mac not supported??

Re: Repository for cool file naming parameter strings

I just noticed a bug in my multiple artist script.  In the old version, the logic for dividing a multiple disc release into separate directories was only called when the album artist was "Various Artists".  Here's the corrected version:

$replace(
$replace(
$replace(
$replace(
$replace(
$replace(
$if($eq(%albumartist%,Various Artists),$if2(%albumartist%,%artist%)/~$left(%album%,1)~/%album%$if(%_releasecomment%, \(%_releasecomment%\),$noop())$if($gt(%totaldiscs%,1),/\(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/$num(%tracknumber%,2) - %artist% - %title%,~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%/$if($gt(%totaldiscs%,1),/\(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/$num(%tracknumber%,2) - %artist% - %title%)
,*,[x])
,?,)
,:,-)
,",')
,<,{)
,>,})


$noop($if2(%albumartist%,%artist%)/%album%/$num(%tracknumber%,2) - %artist% - %title%)

example:
F:\Music CDs\~J~\JUJU\JUJU\(disc 2 - She Sings...)\14 - JUJU - The Rose.mp3

"I say we invite opportunity inside for a nice cup of tea, then hit her on the head and steal her purse." - Kevyn Andreyasn
- Schlock Mercenary by Howard Tayler

Re: Repository for cool file naming parameter strings

Let's see if someone with better scripting skills can lend me a hand.
I would like to combine the following two strings (which I use respectively for single-medium releases and for multiple-medium releases) in a single one, so that I don't have to switch between them.

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

Any idea?

Re: Repository for cool file naming parameter strings

salo.rock wrote:

Any idea?

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

Let me know if that works, should do but I haven't tested.

Re: Repository for cool file naming parameter strings

The default Picard 0.15+ syntax already does the same thing correctly...

Re: Repository for cool file naming parameter strings

voiceinsideyou wrote:

The default Picard 0.15+ syntax already does the same thing correctly...

LOL I didn't realize I (almost) posted the default formatting string. Except for

$num(%discnumber%,1)

instead of 

%discnumber%

- which doesn't do anything useful anyway IMHO.

Re: Repository for cool file naming parameter strings

Thanks for the help, guys.
It's not that obvious that default strings have changed if you're upgrading from an older version. Anyway, I've noticed that we should expect another change with the next release.

68 (edited by FDh 2012-06-11 18:44:34)

Re: Repository for cool file naming parameter strings

salo.rock wrote:

Thanks for the help, guys.
It's not that obvious that default strings have changed if you're upgrading from an older version. Anyway, I've noticed that we should expect another change with the next release.

I don't know if you solved your problem; I had the same with the 0.x version of Picard, nothing worked (the best result I had was the disc number, but I could'nt add the hyphen).
I have retried with the latest version (1.0): it works.

The naming strings, for me, are:
$if($eq(%compilation%,1),
$noop(Various Artist albums)
$if2(%albumartist%,%artist%)/%album%/$if($ne(%totaldiscs%,1),$num(%discnumber%,1)-,)$num(%tracknumber%,2) %title%,
$noop(Single Artist Albums)
$if2(%albumartist%,%artist%)/%album%/$if($ne(%totaldiscs%,1),$num(%discnumber%,1)-,)$num(%tracknumber%,2) %title%)

Giving for a single disc album:
\AC-DC\Back in Black\01 Hells Bells.mp3
and for a multidisc album
\AC-DC\Live\1-03 Back in Black.mp3

(sorry, I have not Beatles multidisc album ! :-) )

Re: Repository for cool file naming parameter strings

FDh wrote:

I don't know if you solved your problem; I had the same with the 0.x version of Picard, nothing worked (the best result I had was the disc number, but I could'nt add the hyphen).
I have retried with the latest version (1.0): it works.

Nothing has changed for the $num or "hyphen adding capabilities" between the two versions; and the default syntax in 0.15-0.16 already added the hyphen just fine so you must have had a mistake in your syntax.

I don't think you're talking about the same thing, but your naming string is overcomplicated with 1.0

a) As soulsearchingsun said earlier $num(%discnumber%,1) does nothing
b) in 1.0 the SA and MA/VA strings have been combined into 1 so if you want the same thing for both, just remove the %compilation% check completely

Giving you a much simpler syntax of

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

which will do exactly the same thing as yours.

... and incidentally is pretty much the same as the default syntax for 1.0:

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

Re: Repository for cool file naming parameter strings

soulsearchingsun wrote:

@tigertales:
$upper($if($eq(%albumartist%,Various Artists),VA,$if2(%albumartist%,%artist%)))/$if($eq(%albumartist%,Various Artists),VA,$lower($if2(%albumartist%,%artist%))) -$if(%date%, $left(%date%,4) -) $lower(%album%)/$if($eq(%albumartist%,Various Artists),VA,%artist%) - $if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) -$if($eq(%albumartist%,Various Artists), %artist% -) %title%


I've just about got this working now with Version 1.0.  ... I just need the 1st letters of the Artist and Album Title Capitalised in the Album folder structure:
eg:
fleet foxes - 2011 - helplessness blues
should become:
Fleet Foxes - 2011 - Helplessness Blues

... and then I owe you a beer.

Re: Repository for cool file naming parameter strings

You can remove the $lower calls (soulsearchingsun specifically added them since your original example you requested had lower case)

$upper($if($eq(%albumartist%,Various Artists),VA,$if2(%albumartist%,%artist%)))/$if($eq(%albumartist%,Various Artists),VA,$if2(%albumartist%,%artist%)) -$if(%date%, $left(%date%,4) -) %album%/$if($eq(%albumartist%,Various Artists),VA,%artist%) - $if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) -$if($eq(%albumartist%,Various Artists), %artist% -) %title%

Re: Repository for cool file naming parameter strings

^ Thanks for your rapid response, but I dont code.  I see now I copied the line from Kamaradski, my bad.
I'd only be guessing which bits to change - would you be kind enough to change it for me??  I'll look to see if I can spot the difference.
Thanks.

Re: Repository for cool file naming parameter strings

I already changed it for you in what I posted above... :)

Re: Repository for cool file naming parameter strings

VIY, thankyou very much.  I see now the a change/removal of 'upper'.  I'll test it today and get back to you.   Is there an easy way to learn this stuff so I dont have to keep coming  back to ask??

Re: Repository for cool file naming parameter strings

The syntax documentation is at http://musicbrainz.org/doc/MusicBrainz_ … /Scripting which tells you the various functions available. This same syntax can be used to alter the metadata in tags themselves in Options > Advanced > Scripting as well as to do stuff in file naming.

The names of the metadata available (e.g. %albumartist%, %title% etc) are at http://musicbrainz.org/doc/MusicBrainz_Picard/Tags

The syntax is similar to other scripting languages however the first paragraph on the scripting page explains the basics.

The syntax is derived from Foobar2000's titleformat. There are three base elements: text, variable and function. Variables consist of alpha-numeric characters enclosed in percent signs (e.g. %artist%). Functions start with a dollar sign and end with an argument list enclosed in parentheses (e.g. $lower(...)).

To use parenthesis or commas as-is inside a function call you must escape them with a backslash.

The best way to learn is by simple experimentation really. :)