26 (edited by Moonbase 2009-01-20 15:45:14)

Re: Repository for cool file naming parameter strings

I use

File naming format:

$if2(%albumartistsort%,%artistsort%)/$if2(%albumartistsort%,%artistsort%) - %album%/%artistsort% - %title%

Multiple artist file naming format:

$if($eq(%albumartistsort%,%artistsort%),%albumartistsort%/%albumartistsort% - %album%/%artistsort% - %title%,%artistsort%/%artistsort% - %title%)

Example:
File name:
M:/Music/Tagged/Beatles, The/Beatles, The - Help/Beatles, The - Ticket to Ride.mp3
Multiple artist file name:
M:/Music/Tagged/Fantasys, The/Fantasys, The - Why_ Oh Why_.mp3

A little odd maybe, but I rely on %albumartistsort% and %artistsort% and require even files from VA albums to show up under the artist folder. (I also rely on Picard adding » (1)«, » (2)« and so forth to the file name if needed.)

VA albums are »held together« only by playlists (in M:/Music/Playlists/Albums/), databases and »media libraries« (broadcasting databases (mySQL); Logitech SqueezeCenter for private listening (mySQL); MusicIP Mixer; Winamp media library).

27 (edited by rmagere 2011-07-03 10:03:48)

Re: Repository for cool file naming parameter strings

Based on some of the posts in this thread and my modifications I use:

Single Artists

$rreplace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if($if2(%originalyear%,%date%), [$left($if2(%originalyear%,%date%),4)])/$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),[*|:"<>?],)

Multiple Artists

$rreplace($replace($if($eq(%albumartist%,Various Artists),AAVV,$rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.)))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if($if2(%originalyear%,%date%), [$left($if2(%originalyear%,%date%),4)])/$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),[*|:"<>?],)

Example:
File name:

Beatles, The\The Beatles - Help! [1965]\07 - The Beatles - Ticket to Ride.mp3
Multiple artist file name:
AAVV\Various Artists - Explosive Doowops, Volume 4 [1999]\05 - The Fantasy - Why Oh Why.mp3

The features of these strings are:
1) Unusable filename characters are removed so that no underscore replacement takes place (i.e. Why Oh Why.mp3 instead of Why_ Oh Why_.mp3)
2) All albums by an artist are collected within the directory using the artist sort name - however within such directory the standard artist name is used
3) The date of the album - if present - is included in the album directory at the end (otherwise omitted). This is done to avoid inconsistent naming between those albums with date information and those without
4) The artist name is kept within the actual filename of track so that were a single song to be extracted from an album the key information would still be available in the filename itself (the fact that the track number is at the very beginning of the file name is to facilitate its removal through manual editing if necessary)

On top of that the following benefits are included and were taken from previous posts:
a. If the ArtistName, AlbumName or TrackName contain a three-dot "..." sequence, it will be replaced with a true ellipsis "…"
b. If the ArtistName or AlbumName ends in a dot "." then that dot will be removed
c. Finally, any and all underscores "_" will be removed from the entire path
d. Multi-artist albums attributed to a specific artist will have files placed into the same directory structure as the single artist albums

EDIT NOTE
The string uses the option %originalyear% and, if not present, %date% to set the date of the album folder. Since the time I have posted the script I have decided to remove the %originalyear% and just use %date% for my personal use. I leave the script here as it is because it is a more complex script and can be easily modified, however it is important that people using it are aware of such choice.


----NEW STRING 23/07/2009---
Based on the discussion in another section of the forum (http://forums.musicbrainz.org/viewtopic … 7896#p7896) I have decided to create an alternative version of the previous string (minus the original year aspect) that groups all discs of a given release in the same release group.
The following strings require:
1. the Disc Numbers plugin (http://musicbrainz.org/doc/PicardQt/Plugins)
2. the Bonus Disc plugin (http://musicbrainz.org/doc/PicardQt/Plugins)
3. the following code added to the Scripting section of Picard

$if(%discnumber%,$set(albumdisc,$if(%discsubtitle%,%album% \(disc %discnumber% - %discsubtitle%\),%album% \(disc %discnumber%\))))
$if(%bonusdisc%,$set(albumdisc,$if(%bonusdisctitle%,%album% \(bonus disc - %bonusdisctitle%\),%album% \(bonus disc\))))

Once (1) to (3) have been carried out the strings are:

Single Artist

$replace($replace($replace($replace($replace($replace($replace($replace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if(%albumdisc%,$rreplace($replace($replace(%albumdisc%,...,…),/,-),\\.\$,$noop(.))/,)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

Multiple Artists

$replace($replace($replace($replace($replace($replace($replace($replace($replace($if($eq(%albumartist%,Various Artists),AAVV,$rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.)))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if(%albumdisc%,$rreplace($replace($replace(%albumdisc%,...,…),/,-),\\.\$,$noop(.))/,)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

As mentioned all the features of the original strings persists (but original year as explained in the previous edit) the additional feature provided by the changes is:

instead of
Beatles, The\The Beatles - Help! (disc 1: Just an example) [1965]\07 - The Beatles - Ticket to Ride.mp3
Beatles, The\The Beatles - Help! (disc 2: Just another example) [1965]\07 - The Beatles - Ticket to Ride.mp3
Beatles, The\The Beatles - Help! (bonus disc: why not) [1965]\07 - The Beatles - Ticket to Ride.mp3[/i]

the end result is
Beatles, The\The Beatles - Help! [1965]\Help! (disc 1 - Just an example)\07 - The Beatles - Ticket to Ride.mp3
Beatles, The\The Beatles - Help! [1965]\Help! (disc 2 - Just another example)\07 - The Beatles - Ticket to Ride.mp3
Beatles, The\The Beatles - Help! [1965]\Help! (bonus disc - why not)\07 - The Beatles - Ticket to Ride.mp3

Furthermore it also includes the updated replacement string developed by Kelani (http://forums.musicbrainz.org/viewtopic.php?id=1769)
Specifically:
?  to  <nothing>
_  to  <space>   
*  to  x    (To note unreleased/demo tracks: 01. SomeBand - SuperSecret Track [x].mp3  )
:  to  <space>-
/  to -               this specific replacement does not appear to work

I have also added the following replacements
" to '
| to <nothing>
< to [
> to ]


NGS update 02 July 2011
Below are the strings I am using with NGS to account for the different treatment of disc numbers
Single Artist

$if2(%albumartistsort%,%artistsort%)/$if2(%albumartist%,%artist%) - %album%$if(%date%, [$left(%date%,4)])$if($gt(%totaldiscs%,1),/%album% \(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/$num(%tracknumber%,2) - %artist% - %title%

Various Artists

$if($eq(%albumartist%,Various Artists),AAVV/,$if2(%albumartistsort%,%artistsort%)/$if2(%albumartist%,%artist%) - )%album%$if(%date%, [$left(%date%,4)])/$if($gt(%totaldiscs%,1),/%album% \(disc %discnumber%$if(%discsubtitle%, - %discsubtitle%)\))/$num(%tracknumber%,2) - %artist% - %title%

For clarity I have removed the "replace" parts of the code

The code with the missing "replace" is below:
Single Artist

$replace($replace($replace($replace($replace($replace($replace($replace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if($gt(%totaldiscs%,1),/$rreplace($replace(%album%,...,…),\\.\$,$noop(.)) \(disc %discnumber%$if(%discsubtitle%, - $rreplace($replace(%discsubtitle%,...,…),\\.\$,$noop(.)))\)/)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

Multiple Artists

$replace($replace($replace($replace($replace($replace($replace($replace($replace($if($eq(%albumartist%,Various Artists),AAVV/,$rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - )$rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if($gt(%totaldiscs%,1),/$rreplace($replace(%album%,...,…),\\.\$,$noop(.)) \(disc %discnumber%$if(%discsubtitle%, - $rreplace($replace(%discsubtitle%,...,…),\\.\$,$noop(.)))\)/)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

Update 03 July 2011
A variation that was introduced in the previous string is the following: if the album artist is "Various Artist" then the files are saved within the folder AAVV\Album (and individual discs if present) rather than (as was the case with previous strings) into AAVV\Various Artists - Album.
The key reason behind the change was ease of access: i.e. if an album is sitting within the AAVV folder I already know it's a "Various Artist" and as such it does not provide further insight into the data and it's less easy to access the directories when browsing the folders.

The change however introduced a secondary annoyance: a significant number of albums start with "The ". This is not an issue when the directories are structured "Artist - Album", but it's not the behaviour I want when the directories are named "Album" only.
As I do not believe there is a %albumsort% variable (as there is %artistsort%) I have made the following modification:

1. Scripting section added the line:

$set(albumsorted,$if($eq(%albumartist%,Various Artists),$if($eq($left(%album%,4),The ),$right(%album%,$sub($len(%album%),4)) \(The\),%album%),%album%))

This script creates a variable called %albumsorted% which (when the album artist is Various Artist and the album name starts with "The ...") stores the value "Album (The)" (rather than "The Album")

2. Single artist (unchanged from 02 July 2011)

$replace($replace($replace($replace($replace($replace($replace($replace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if($gt(%totaldiscs%,1),/$rreplace($replace(%album%,...,…),\\.\$,$noop(.)) \(disc %discnumber%$if(%discsubtitle%, - $rreplace($replace(%discsubtitle%,...,…),\\.\$,$noop(.)))\)/)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

3. Multiple artists

$replace($replace($replace($replace($replace($replace($replace($replace($replace($if($eq(%albumartist%,Various Artists),AAVV/,$rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace($replace($if2(%albumartist%,%artist%),...,…),/,-),\\.\$,$noop(.)) - )$rreplace($replace(%albumsorted%,...,…),\\.\$,$noop(.))$if(%date%, [$left(%date%,4)])/$if($gt(%totaldiscs%,1),/$rreplace($replace(%album%,...,…),\\.\$,$noop(.)) \(disc %discnumber%$if(%discsubtitle%, - $rreplace($replace(%discsubtitle%,...,…),\\.\$,$noop(.)))\)/)$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),?,),_, ),*,x),:, -),",'),|, ),<,[),>,])

Re: Repository for cool file naming parameter strings

Thanks to everyone, especially Ullic Pendragon, for their code.

I was just having a problem with the renaming process - whenever Picard renames a file in the format laid out by Ullic Pendragon, and creates the new folders to accomodate it, if the file is in a folder within my general "music" folder, it creates the files in that folder instead of moving files out to the general directory.

For example, this is the course of a file 1.mp3:

starts here:
//music/Beirut - Holland/1.mp3
moves here:
//music/Beirut - Holland/[-=B=-]/Beirut/Holland/1.mp3
instead of
//music/[-=B=-]/Beirut/Holland/1.mp3


Can anyone help me correct this problem?

Thanks

Re: Repository for cool file naming parameter strings

Just a guess, but try checking that the value of Options > File Naming > Move Files > "Move tagged files to this directly" is set to //music, opposed to "."?

Re: Repository for cool file naming parameter strings

That took care of it. Thanks for the help!

Re: Repository for cool file naming parameter strings

Here's another one for those that are freaked out by coding like me.  I just got a little lucky after looking at the previous posts and did a little tweaking, but they seem to work.  If someone familiar with coding could dbl check these it would be great.  Given that I have only been using MB for a few days and really don't understand the coding.

All thanks go to
rmagere
Moonbase
UllicPendragon

Single

 $rreplace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/$rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if($if2(%originalyear%,%date%), [$left($if2(%originalyear%,%date%),4)])/$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),[*|:"<>?],)

Multiple

 $rreplace($replace($if($eq(%albumartist%,Various Artists),AAVV,$rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.)))/$rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if($if2(%originalyear%,%date%), [$left($if2(%originalyear%,%date%),4)])/$num(%tracknumber%,2) - $rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $replace(%title%,...,…),_,$noop(.)),[*|:"<>?],)

Example
Single Output:
M:\Music\Beatles, The\Help! [1965]\07 - The Beatles - Ticket to Ride.mp3

Multiple Output:
M:\Music\AAVV\Explosive Doowops, Volume 4 [1999]\05 - The Fantasys - Why Oh Why.mp3

Features
Same as rmagere's post above only that the album folder does not contain the artist name.
ie... \%artist name%\%Album% - %Year%\%track% - %Artist% - %Title%

Thanks to everyone at MusicBrainz for a great program!  I have been looking for a GREAT program like this forever.

Re: Repository for cool file naming parameter strings

hello, i need some nice support, because i'm not confirmed in managing of many tracks...cheese. i have now an external hdd and i am clean up my mp3 files, so i want to creating a database. i show just my structur, like its seems in the next life.one especially question? how do i manage my tracks which are in german language, they should to create in a master path "X:\MP3\~ Deutsche Musik (~ German Music)\......

Examples:

Artists =   "X:\MP3\Album\Hard-Rock\A\AC-DC\1990\AC-DC_-_The_Razor's_Edge_(1990)-Hard-Rock-V5-\101-AC-DC_-_Thunderstruck.mp3"

Sampler = "X:\MP3\Sampler\~ VA\~ Boxset (if it used)\Funk\N\Nighttime_Lovers\2009\VA_-_Nighttime_Lovers_Collector's_Box_12CD's_2009)-Funk-V5-\CD11\
1113-Glass_-_Let_Me_Feel_Your_Heartbeat.mp3" (it is track number 135 und the last in this cd).

Playlists = "X:\Playlisten\2009\04-2009\Sampler\~ VA\N\Nighttime_Lovers\VA_-_Nighttime_Lovers_Collector's_Box_12CD's_2009)-Funk-V5-.m3u (included then all tracks)


is there some medicine for me ... **smile**

Re: Repository for cool file naming parameter strings

Hi monchichi, you may want to start a new topic for your questions as this topic is more for different naming strings that people are wanting to share rather than for troubleshooting issues, you will get more replies that way.  Picard cannot yet handle things like German Music or  Sampler as tags to use for naming and grouping music.
To do this would likely need a plugin or picard script and if you could set a tag such as Grouping to hold the info for German Music then you could use it for file naming. 
Maybe scan files in different sessions, like do all your german music and set "Move tagged files to folder" X:\MP3\~ Deutsche Musik (~ German Music)\      and then tag your samples and change the destination to X:\MP3\Sampler\

Re: Repository for cool file naming parameter strings

mll wrote:

It may be a good idea to to some benchmark on how everyone uses the powerful file naming parameters of PicardQt.

Here are the ones I uses at the moment, I seem to be perfectly happy with them. For both, you'll need this plugin if you run Picard0.9.0Alpha9 or less.

Does this plugin avoid the truncation of song titles?

If not, how do I avoid song titles being truncated when I view them in Windows Media Player?

Re: Repository for cool file naming parameter strings

jonsonchong wrote:

Does this plugin avoid the truncation of song titles?

If not, how do I avoid song titles being truncated when I view them in Windows Media Player?

http://wiki.musicbrainz.org/Picard_FAQ# … _Player.21

36 (edited by jecottrell 2009-06-15 20:14:20)

Re: Repository for cool file naming parameter strings

I am trying to retag some of my daughter's compilation CD-Rs that she made. So they have a bunch of different artists/album sources. When I retag them I'd like MusicBrainz to create a new artist folder (or use the existing), then a new album folder (or use the existing) and save the retagged file there.

Can I do that with the right string? Is there one already listed here?

Thanks,

John




EDIT:


I think I got it. I needed to check "move" files.



.

Re: Repository for cool file naming parameter strings

I could need some good advice on an script i tried to "create". I took the one rmagere postet a little up here and mainly changed the running order, but Picard tells me, there would be some kind of error. The occuring error reads: "File naming format: Unexpected character '(' at position 247, line 1.
The preview should have shown: /Beatles, The/1962 - Help!/The Beatles - 07 - Ticket to ride.mp3

My script:

$rreplace($replace($rreplace($replace($replace($if2(%albumartistsort%,%artistsort%),...,…),/,-),\\.\$,$noop(.))/ [$left($if2(%originalyear%,%date%),4)]) - $rreplace($replace(%album%,...,…),\\.\$,$noop(.))$if($if2(%originalyear%,%date%)\$rreplace($replace($replace(%artist%,...,…),/,-),\\.\$,$noop(.)) - $num(%tracknumber%,2) - $replace(%title%,...,…),_,$noop(.)),[*|:"<>?],)

Does anyone find a problem, or can solve it with an other script?
Thanks, Simon

38 (edited by wentuq 2009-11-19 21:18:41)

Re: Repository for cool file naming parameter strings

File Naming Format:

$set(issoundtrack,$if($eq(%releasetype%,soundtrack),1,0))
$set(artist,$if2(%albumartist%,%artist%))
$set(artist,$if($eq($left(%artist%,4),The ),$rreplace(%artist%,^The ,)\, The,%artist%))
$set(title,$replace(%title%,...,…))
$set(album,$replace(%album%,...,…))
$set(date,$left(%date%,4))
$set(albumdate,$if(%date%,%date%-%album%,%album%))
$set(tracknumber,$if(%tracknumber%,$if($eq(%tracknumber%,0),0,%tracknumber%),0))
$set(tracknumber,$if($eq(%tracknumber%,0),%tracknumber%,$if($eq($len(%tracknumber%),3),$num(%tracknumber%,3),$num(%tracknumber%,2))))
$set(tracktitle,$if($eq(%tracknumber%,0),%title%,%tracknumber%-%title%))
$if($eq(%issoundtrack%,1),OST/%album%/%tracknumber%-%artist%-%title%,%artist%/%albumdate%/%tracktitle%)

Multiple Artist file naming format:

$set(issoundtrack,$if($eq(%releasetype%,soundtrack),1,0))
$set(title,$replace(%title%,...,…))
$set(album,$replace(%album%,...,…))
$set(tracknumber,$if(%tracknumber%,$if($eq(%tracknumber%,0),0,%tracknumber%),0))
$set(tracknumber,$if($eq(%tracknumber%,0),%tracknumber%,$if($eq($len(%tracknumber%),3),$num(%tracknumber%,3),$num(%tracknumber%,2))))
$set(trackartisttitle,$if($eq(%tracknumber%,0),%artist%-%title%,%tracknumber%-%artist%-%title%))
$if($eq(%issoundtrack%,1),OST/%album%/%tracknumber%-%artist%-%title%,VA/%album%/%trackartisttitle%)

Preview Results

/media/drive/picard/Beatles, The/1965-Help!/07-Ticket to Ride.mp3
/media/drive/picard/VA/Explosive Doowops, Volume 4/05-The Fantasys-Why? Oh Why?.mp3

*This code is really easy to change

Re: Repository for cool file naming parameter strings

Looking to rename files to Artist Name - Album - Tracknumber 0 infront - track name

can anyone list that? thanks. I don't want the track number first. I want the artist name first.

40 (edited by ym 2009-08-02 10:42:06)

Re: Repository for cool file naming parameter strings

daeros wrote:

Looking to rename files to Artist Name - Album - Tracknumber 0 infront - track name

can anyone list that? thanks. I don't want the track number first. I want the artist name first.

I guess by "Artist Name" you want the Album Artist not the track artist. If so, you can use:

%albumartist% - %album% - $num(%tracknumber%,2) - %title%

And I would suggest having track artist for multiple artist releases. Something like:

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

Re: Repository for cool file naming parameter strings

I use this to keep my files under the 42 max character limit for the FATX filesystem on my Xbox (I was using it as a standalone jukebox / media player)

$left($if2(%albumartist%,%artist%),42)/$left(%album%,42)/$num(%tracknumber%,2) $left(%title%,38)

Re: Repository for cool file naming parameter strings

Thx wentuq, your code looks greate. I tried to improve it a little bit, but failed.
I'd like to replace / in atrist or title with a blank:
$set(artist,$replace(%artist%,/, ))

But this code doesn't work. AC/DC is still named as AC_DC.

Can anyone help?

Re: Repository for cool file naming parameter strings

This is actually a full-length script I've used, not just a file-naming string. I can't guarantee that this example is perfect - it's a few weeks old and I've moved on since then, so there may be a couple of wonky bits to this one in some situations. It may be useful to some people starting out with scripting, since it illustrates syntax required for tagger scripts in lots of different situations; the script is roughly 40 lines long, and uses a large number of the tagger functions and several of the tag variables (as well as some custom variables).

First, the code itself:

$set(true,-1)
$set(false,0)
$set(IsMusicBrainz,%true%)
$set(SpecialReleaseType,%false%)
$if2(
    $if($eq($len(%musicbrainz_albumid%),0),Music - No MBID$set(IsMusicBrainz,%false%)),
    $if($eq(%releasetype%,live),Music - Live),
    $if(
        $or(
            $or(
                $eq(%releasetype%,spokenword),
                $eq(%releasetype%,audiobook)
            ),
            $eq(%releasetype%,interview)
        ),Spoken Word
    ),
    $if($eq(%releasetype%,soundtrack),Music - Soundtrack),
    $if($in(%album%,Promo Only), Music - Promo Only$set(IsMusicBrainz,%false%)),
    $if(
        $and(
            $lt($matchedtracks(),%totaltracks%),
            $lt($matchedtracks(),60)
        ),Music - Incomplete Releases),
    Music$if(%releasetype%,$set(SpecialReleaseType,%true%))
)/

$if2(%albumartist%,%artist%)/

%album%
$if(%releasecountry%, - %releasecountry%)
$noop($if(%SpecialReleaseType%, - %releasetype%))

$if(%IsMusicBrainz%,
    $set(_y_,$if2($left(%originaldate%,4),$left(%date%,4)))
    $if($in(%album%,%_y_%),, - %_y_%)
)/

%tracknumber%
$if($ne(%artist%,%albumartist%), - %artist%)
 - %title%

I'll break this down and go through it below.

Before getting into that, let me point out something important that can be a barrier to understanding Picard's tagging. Picard reads the content of a tagger script and does the following:
- if it sees a line break or tab, it discards it. That lets you put things on multiple lines and indent them easily.
- if it sees something that is a known function - it looks like $<something>( ... ) - the code gets evaluated using the special function $<something>. If the function returns some value, that gets added to a string Picard is using to build the save path for the music file it's working with. There may be nothing returned from a function, however; $set() and $noop() won't return anything, and $if() and $if2() might not return a value.
- if it sees a variable (surrounded with % marks), Picard substitutes in the value of the variable and adds that to the string it's building. If the variable is empty, then nothing gets added.
- Text characters outside functions and variables are added literally. This lets you directly add spaces, words, or the "/" marks that identify folders.


Initial setup
I start out by setting up some things I'll use later:

$set(true,-1)
$set(false,0)
$set(IsMusicBrainz,%true%)
$set(SpecialReleaseType,%false%)

This creates variables named %true% (with a value of -1), %false% (with a value of 0), %IsMusicBrainz% (with an initial value of %true%), and %SpecialReleaseType% with a value of %false%.

First step - setting the collection folder

The following $if2 block returns the first non-empty value from its list. What this does, in effect, is return a string that becomes a top-level folder for a media collection. I have the default output folder set to D:\Data in Picard, so each collection becomes a named folder under that.

$if2(
    $if($eq($len(%musicbrainz_albumid%),0),Music - No MBID$set(IsMusicBrainz,%false%)),
    $if($eq(%releasetype%,live),Music - Live),
    $if(
        $or(
            $or(
                $eq(%releasetype%,spokenword),
                $eq(%releasetype%,audiobook)
            ),
            $eq(%releasetype%,interview)
        ),Spoken Word
    ),
    $if($eq(%releasetype%,soundtrack),Music - Soundtrack),
    $if($in(%album%,Promo Only), Music - Promo Only$set(IsMusicBrainz,%false%)),
    $if(
        $and(
            $lt($matchedtracks(),%totaltracks%),
            $lt($matchedtracks(),60)
        ),Music - Incomplete Releases),
    Music$if(%releasetype%,$set(SpecialReleaseType,%true%))
)/

Here's a quick re-listing of each segment of the code, followed by the explanation about the collection folder that segment causes Picard to use.


    $if($in(%album%,Promo Only), Music - Promo Only$set(IsMusicBrainz,%false%)),

If the album name includes 'Promo Only' (the name of a specialized DJ collection that is often not categorized in MusicBrainz), I set the collection to Music - Promo Only. We also set the IsMusicBrainz variable to false.

    $if($eq($len(%musicbrainz_albumid%),0),Music - No MBID$set(IsMusicBrainz,%false%)),

This sets our collection folder to Music - No MBID; I use it for items that aren't recognized by MusicBrainz for whatever reason - either they're private or they're audio not yet listed that I don't have time to enter into MusicBrainz. It also sets the IsMusicBrainz value to false.

    $if(
        $and(
            $lt($matchedtracks(),%totaltracks%),
            $lt($matchedtracks(),60)
        ),Music - Incomplete Releases
    ),

If we're missing some items from a release, we set the collection folder to  Music - Incomplete Releases. Note that I use the undocumented $matchedtracks() function. This FAILS on clusters that haven't been identified since they don't have a proper musicbrainz album id used for track match counts. Note also that I only enforce redirection if the cluster has less than 60 tracks; this prevents misdirecting albums that have lots of silent tracks (which I don't retain).

    $if($eq(%releasetype%,live),Music - Live),

Sets collection folder to Music - Live if the MusicBrainz releasetype is 'live'.

    $if(
        $or(
            $or(
                $eq(%releasetype%,spokenword),
                $eq(%releasetype%,audiobook)
            ),
            $eq(%releasetype%,interview)
        ),Spoken Word
    ),

Sets the collection folder to Spoken Word if the releasetype is spokenword, audiobook, or interview. Since the $or function can only take 2 values from a script, I had to nest multiple $or functions to test all three conditions.

    $if($eq(%releasetype%,soundtrack),Music - Soundtrack),

Sets the collection folder to Music - Soundtrack if the releasetype is soundtrack.

    Music$if(%releasetype%,$set(SpecialReleaseType,%true%))
The final item is the word 'Music'; if nothing has been matched before this, our collection folder will be Music. I also set SpecialReleaseType to true if there IS a releasetype defined. I can use this later to tell me if the particular release does have a releasetype defined, but it isn't spokenword/live/audiobook/interview/soundtrack.

At the very end of the section, we have

/

by itself, so whatever value Picard pulled from the $if2 function becomes a folder.

Selecting the artist folder
This is pretty simple. I use the ReleaseArtist (%albumartist%) as the artist folder for everything; if there is no albumartist defined in the ID3 tags, then this defaults to %artist%. It's then followed by a terminal / mark to make sure this becomes a folder, like this:

$if2(%albumartist%,%artist%)/

Setting up release folder
To prevent name collisions or accidental mixups among distinct releases that have the same names, I try to ensure that all releases are in distinct folders. This means I need more than just the album name as a folder. The following is my basic code for doing the entire folder:

%album%
$if(%releasecountry%, - %releasecountry%)
$noop($if(%SpecialReleaseType%, - %releasetype%))

$if(%IsMusicBrainz%,
    $set(_y_,$if2($left(%originaldate%,4),$left(%date%,4)))
    $if($in(%album%,%_y_%),, - %_y_%)
)/

I start with the album name (%album%).
Then, if there is a release country, I add " - %releasecountry%"
Although current disabled using $noop( .. ), I can also add releasetype easily with $if(%SpecialReleaseType%, - %releasetype%). This lets me automatically add ep/album/compilation/remix/single if I need it to disambiguate (for example, a single and an album released with the same name in the same year in the same country).
The last part is to add a date. This is a bit complicated.
First, I don't want to add a date for albums that aren't in the MusicBrainz database, since they may be ad-hoc collections that have different year tags, so I only run the code for adding the date if %IsMusicBrainz% which I set earlier is still true. If so, then I get the date, but I want to do it a particular way to ensure that I DO get possible collisions when duplicating data. I want to select the original date for the album rather than a particular release date if at all possible. Since MusicBrainz returns dates in the form yyyymmdd, I just get the first 4 numbers in %originaldate% if it exists, and use %date% (the release date) if not. I then put this value into the variable %_y_%.
The reason I do this is to handle a couple of peculiar cases that I find irritating.
First of all, I want to have find out whether the release year I have shows up in the album name. If so, I don't want to use the year in the album name; otherwise, I'll get things like this:
Baz Hits of Summer 2005 (disc 1) - GW - 2005
so I actually test to see if %_y_% is in the album name. If it is, I do nothing. If it isn't I go ahead and add " - %_y_%" to the release folder name I'm building, and end with the / that turns it into a folder.

Naming the file
The last step is naming the music file. This has 3 parts, on 3 lines for clarity:

%tracknumber%
$if($ne(%artist%,%albumartist%), - %artist%)
 - %title%

The %tracknumber% simply begins the file name with the track number.
The next line checks to see whether the artist is the same as the album artist. If and only if it isn't, then " - <artist>" gets added to the file name.
Finally, we add " - " and the title to the end.

44 (edited by PeteJames 2010-02-20 09:44:51)

Re: Repository for cool file naming parameter strings

Just got Picard as other tag and renamers for mac aren't great and this looks superb, thanks!

I want to format the file renaming as such: 01 Artist - Track

Is this ok?

$num(%tracknumber%,2) %artist% - %title%

With Title Case Enabled

What code do I need to do this in the renaming tab of preferences?

For Tags I just want them in title case

Also is there a way to rename folders automatically?

Thanks!

Edit: one problem i've come across is that I want the remix to always show 01 Artist - Track (Remix)  (if the track is a remix)
How do I make sure the remix is in brackets?

Re: Repository for cool file naming parameter strings

I've been using Picard for about a week now. It's a wonderful tool! Exactly what I have been searching for :)

Today I decided to built a file naming script. It's a mixture of scripts in this forum.

$noop(<!-- MusicBrainz Picard naming script -->)
$noop(<!-- Version 0.3 by CodeAddict -->)
$noop(<!-- Requires discnumbers and bonusdisc plugins -->)

$set(do_album,1)

$noop(<!-- Setup character replacements -->)
$replace($noop(?)
$replace($noop(:)
$replace($noop(")
$replace($noop(|)
$replace($noop(<)
$replace($noop(>)

$noop(<!-- Category -->)
$if2(
$if($eq($len(%musicbrainz_albumid%),0),Unsorted$set(do_album,0)),
$if($eq(%releasetype%,live),Live),
$if($or($or($eq(%releasetype%,spokenword),$eq(%releasetype%,audiobook)),$eq(%releasetype%,interview)),Spoken),
$if($eq(%releasetype%,soundtrack),Soundtracks),
$if($in(%album%,Promo Only),Promos),
$if($eq(%releasetype%,remix),Remixes),
$if($or($eq(%releasetype%,single),$eq(%releasetype%,ep)),Singles),
$if($eq(%album%,[non-album tracks]),Tracks$set(do_album,0)),
$if($or($eq(%releasetype%,compilation),$eq(%albumartist%,Various Artists)),Compilations),
Albums
)/

$if($eq(%do_album%,1),

$noop(<!-- Artist -->)
$rreplace($replace($if2(%albumartist%,%artist%),...,…),\\.\$,)/

$noop(<!-- Album -->)
$set(album,$rreplace($replace(%album%,...,…),\\.\$,))
$noop(<!-- Group VA's under the first letter of the album name -->)
$noop(<!-- Album names beginning with 'The ' are grouped under the 5th letter -->)
$noop(<!-- The release date comes after the album name -->)
$if($eq(%albumartist%,Various Artists),
$if($eq($left(%album%,4),The ),$right($left(%album%,5),1),$left(%album%,1))/
%album%$if(%date%, [$left(%date%,4)]),
[$if(%date%,$left(%date%,4),____)] %album%)
$noop(<!-- If the album has a known label, append it -->)
$if(%label%, {%label%})/

$noop(<!-- Disc -->)
$set(format,$if2(%format%,CD))
$set(disc,$if(%discnumber%,%format% %discnumber%$if(%discsubtitle%, - %discsubtitle%),
$if(%bonusdisc%,%format% Bonus$if(%bonusdisctitle%, - %bonusdisctitle%))))
$if(%disc%,$rreplace($replace(%disc%,...,…),\\.\$,)/)

)

$noop(<!-- Track -->)
$num(%tracknumber%,2). 
$rreplace($replace(%artist%,...,…),\\.\$,) - 
$rreplace($replace(%title%,...,…),\\.\$,)

$noop(<!-- Perform character replacements -->)
,>,\))
,<,\()
,|,)
,",')
,:, -)
,?,)

BTW, indentation in the script language would be nice :P

Re: Repository for cool file naming parameter strings

Hi Guys,

I'm using a slightly modified version of a naming string from upthread -- for the most part it's just what I want, but I do have one complaint and I was hoping someone might help me out.  Here's the string:

$left($if2($rreplace(%artist%,\(The|A\) \(.*\),\\2)),1)/$if2($rreplace(%artist%,\(The|A\) \(.*\),\\2)) - $left(%date%,4) %album%/$rreplace(%artist%,\(The|A\) \(.*\),\\2) - $num(%tracknumber%,2) %title%

I like the part that removes any leading "The" or "A" from an artist name.  The problem is that it doesn't just remove a leading "The" or "A" ... it removes ANY "The" or "A".  So for example, instead of "At The Drive-In" I get "At Drive-In".  Bummer!

This might be due to the fact that I'm using the "Title Case" plugin?  Just a guess.  Anyway can someone advise me as to how I can make the little remove string apply to only the leading "The" or "A" instead of to any in the name?  Thanks in advance.

Re: Repository for cool file naming parameter strings

radiosig wrote:

Anyway can someone advise me as to how I can make the little remove string apply to only the leading "The" or "A" instead of to any in the name?

Put a ^ before The and A in the various places in the script. That will ensure it only replaces those at the start of the field. The Title Case plugin shouldn't affect this.

Re: Repository for cool file naming parameter strings

voiceinsideyou wrote:
radiosig wrote:

Anyway can someone advise me as to how I can make the little remove string apply to only the leading "The" or "A" instead of to any in the name?

Put a ^ before The and A in the various places in the script. That will ensure it only replaces those at the start of the field. The Title Case plugin shouldn't affect this.

This worked like a charm.  Thanks so much!

Re: Repository for cool file naming parameter strings

alright for some reason I am lost...

I have MB setup to move my files to a new directory //media/Media/Music2/ when it moves it there I just want to have each albumartist to have their own folder and within each albumartists folder their albums will be there. The file name I just want to be 0x - Title.ext

right now I have

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

but the example isn't displaying correctly

/home/shizzle/07 - Ticket to Ride.mp3

for some reason its not displaying the example as

/media/Media/Music2/The Beatles/Help!/07 - Ticket to Ride.mp3

Re: Repository for cool file naming parameter strings

You probably need to enable "Moving files" on the respective options tab, checking "Move files to this directory when saving". Otherwise Picard does renames the files, but doesn't have any of them. The Picard user interface is very confusing in this regard, unfortunately.