1 (edited by mll 2007-05-13 10:12:28)

Topic: Repository for cool file naming parameter strings

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.

File naming format

_Unique/$if2(%albumartist%,%artist%)/$left(%date%,4) - $if($gt($len(%album%),50),$left(%album%,25)\(...\)$right(%album%,20),%album%)/$num(%tracknumber%,2)-$num(%totaltracks%,2) - $left(%title%,50)

Multiple artist file naming format

$if($eq(%albumartist%,Various Artists),_Various,_Unique/$if2(%albumartist%,%artist%))/$if($ne(%albumartist%,Various Artists),$left(%date%,4) - )$if($gt($len(%album%),50),$left(%album%,25)\(...\)$right(%album%,20),%album%)/$num(%tracknumber%,2)-$num(%totaltracks%,2) - %artist% - $left(%title%,50)

Advantages:
* distinguishes Various artists from single artists releases. Yet, if a VA artist album is attributed to an artist (example), it goes into the single artists directory.
* track names always start in this kind: 01-12 02-12 03-12, hence players play them in the right order (often they consider 10-12 is before 2-12)
* prevents problems with pathes and filenames that'd be too long (and it could happen often with classical relases)
* releases are sorted per year, for discography's sake

Feel free to ask if something's not clear in it.


And if we have many interesting ideas in this thread, we might wikify it.

Re: Repository for cool file naming parameter strings

I decided to sticky this in case other people have good suggestions as well.

This is what I use right now.

$replace($left(%albumartist%,1)/%albumartist%/%album%/$num(%tracknumber%,2) %title%,_,)

The results are...
http://img143.imageshack.us/img143/6822/picardstringtf6.png

In addition it also removes the underscores from filenames and folder structures. I added it because the Windows incompatible character replacement is underscore. It's not perfect of course, because obviously it will also remove underscores that for some reason need to be there. Can't think of any examples, but I'm sure there are some.

Re: Repository for cool file naming parameter strings

This is my first message, so hello there!

I'd like to know, if anyone can help, how can I set the path for the files to be correctly moved to the same directory where they are. I basically want my folders to be renamed, leaving the files where they are. Thanks in advance

If anyone tells what parameter stands for the year of the release of the album, I can start working on it. Thanks!

Re: Repository for cool file naming parameter strings

Hi iTor,
a little search in the forum ...
you find both informations you had asked for in this topic: http://forums.musicbrainz.org/viewtopic.php?pid=3445

$left(%date%,4)
and for the same directory you use "."
cheers

Re: Repository for cool file naming parameter strings

This is what I use:

$set(discnumber,$rsearch(%album%,\\\(disc \(\\d+\)\\\)))$set(album,$rreplace(%album%,\\s\\\(disc \\d+\\\),))$if2(%albumartist%,%artist%)/($left(%date%,4)) $lower(%album%) $replace($replace($replace($replace([%releasetype%],compilation,comp),single,CDS),soundtrack,OST),[album],)/$if(%discnumber%,CD%discnumber%)/$num(%tracknumber%,2) - $lower(%title%) (%artist%)

http://img141.imageshack.us/img141/894/screenhunter07200803281pf5.png

6 (edited by dak180 2011-06-13 03:03:38)

Re: Repository for cool file naming parameter strings

Required Plugins
Disc Numbers
Bonus Disc

TaggerScript

$if($eq(%album%,[non-album tracks]),$set(tracknumber,0) $set(totaltracks,0))
$if($ne(%album%,[non-album tracks]),$if(%discnumber%,$noop(.),$set(discnumber,1) $set(totaldiscs,1)))
$if($eq(%releasetype%,soundtrack),$set(genre,Soundtrack))
$if($eq($right(%subtitle%,8),Last.fm),$unset(subtitle)$unset(comment:))

File naming format

$if2(%albumartist%,%artist%)/$if($ne(%album%,[non-album tracks]),%album%/)$if($gt(%totaldiscs%,1),$if(%discsubtitle%,$num(%discnumber%,2) %discsubtitle%,Disc %discnumber% of %totaldiscs%)/)$if(%bonusdiscs%,Bonus$if(%discsubtitle%, %discsubtitle%)/)$num(%tracknumber%,2) - %artist% - %album% - %title%

Notes
You will still have to set the totaldiscs variable yourself, but you can select all the the tracks and set them all at the same time, so it is not so bad.

Results

Beangrowers/Not in a Million Lovers/01 - Beangrowers - Not in a Million Lovers - Quaint Affair.mp3
Red Hot Chili Peppers/Stadium Arcadium/02 Mars/02 - Red Hot Chili Peppers - Stadium Arcadium - Tell Me Baby.mp3
Loreena McKennitt/Live in Paris and Toronto/Disc 1 of 2/04 - Loreena McKennitt - Live in Paris and Toronto - Marco Polo.mp3
Various Artists/Brother Bear/01 - Phil Collins - Brother Bear - Look Through My Eyes.mp3
The world is a dream, but you are not the dreamer. | The world is all a game, you're the one being played.
And yet more quotes ...

7 (edited by msgflaw 2008-06-01 19:05:23)

Re: Repository for cool file naming parameter strings

Mine is similar to Kilu's in that it puts the artist folder under a folder for the first letter of the artist name, except that mine will not put artists whose name starts with "The " into the "T" folder.

The following is what I am using now.

File naming format:

$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))/$if2(%albumartist%,%artist%)/$if(%date%,$left(%date%,4) -- )%album%/$num(%tracknumber%,2). %title%

Multiple artists file naming format:

$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))/$if2(%albumartist%,%artist%)/$if(%date%,$left(%date%,4) -- )%album%/$num(%tracknumber%,2). %artist% - %title%

The Picard preview says this:

File name:
E:\Music\Picarded\B\The Beatles\1965 -- Help!\07. Ticket to Ride.mp3
Multiple artist file name:
E:\Music\Picarded\V\Various Artists\1999 -- Explosive Doowops, Volume 4\05. The Fantasys - Why  Oh Why .mp3

"The Beatles" is put into into the "B" folder. "Nick Cave & The Bad Seeds" would be put into the "N" folder.

Re: Repository for cool file naming parameter strings

A better way to remove "The " or move it to the end would be to use MB's sort names; %albumartistsort% and %artistsort%.

It would of course change "Nick Cave" to be filed under "Cave, Nick" unless you added a "$if($eq($left($if2(%albumartist%,%artist%),4),The ), .....) type of condition though.

9 (edited by msgflaw 2008-06-11 05:35:56)

Re: Repository for cool file naming parameter strings

I didn't know about %albumartistsort% and %artistsort%. I think I still want the Nick Cave folder to be unmodified, though. Like you said, it looks like the format string could be shortened using the sort names and an $if. Thanks.

10 (edited by UllicPendragon 2008-06-10 22:47:24)

Re: Repository for cool file naming parameter strings

Hi folks,

I've taken some of your ideas and customised them for my own purposes and, for the most part, it works great. One thing I can't seem to get to work quite right is the $replace() function. I'd like to get rid of any and all underscores that get introduced into the folder and file names. This works in all cases except for when a folder name ends in a period (.) that gets automatically replaced with an underscore. The $replace() function doesn't seem to recognise this underscore. How can I make sure it replaces this underscore along with all the others?

Here is my code:
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)=-])/$if2(%albumartist%,%artist%)/$if(%date%,[$left(%date%,4)] )%album%/$num(%tracknumber%,2) - %title%,_,)

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)=-])/$if2(%albumartist%,%artist%)/$if($ne(%albumartist%,Various Artists),$if(%date%,[$left(%date%,4)] )))%album%/$num(%tracknumber%,2) - %artist% - %title%,_,)

Preview Results
File name:
C:\My Downloads\NewlyTagged\[-=B=-]\The Beatles\[1965] Help!\07 - Ticket to Ride.mp3
Multiple artist file name:
C:\My Downloads\NewlyTagged\[~Various Artists~]\Explosive Doowops, Volume 4\05 - The Fantasys - Why Oh Why.mp3

For example, for the artist W.A.S.P. the folder's name would come out as "W.A.S.P_" instead of the "W.A.S.P." or "W.A.S.P" formats that I'd prefer. Same with Andrew W.K. or Big Wreck's In Loving Memory of... album which gets written as "In Loving Memory of.._" Worse, Sixx:A.M. comes out as "Sixx_A.M_" -- Argh!

I'd appreciate any feedback you can provide. Thanks!

Edit: Added the Picard preview results for my code

Re: Repository for cool file naming parameter strings

Picard should replace every starting period with an underscore, because a starting period causes problems in most operating systems. But I'm surprised that it does replace trailing periods, I'll have a look at this.

12 (edited by outsidecontext 2008-06-11 08:20:45)

Re: Repository for cool file naming parameter strings

UllicPendragon: I had a look, the trailing period gets replaced only on windows, as it seems to make problems there. This replacement happens after the scripting was applied to the filename. The only thing you can do about this is replacing the trailing period yourself with something you prefer. You might want to use the $rreplace(text,pattern,replace) function, with a pattern like "\.$" for this. See http://wiki.musicbrainz.org/PicardScripting for details.

Or you could disable the "replace unsafe characters" option in Picard, this will disable the replacement, too.

Re: Repository for cool file naming parameter strings

Thanks for the reply, outsidecontext.

Hmm... maybe I'm being a moron but I can't seem to get that pattern to work in Picard? For the sake of brevity, I'll post just the affected portion of my code:

$rreplace($replace($if2(%albumartist%,%artist%)/$if(%date%,[$left(%date%,4)] )%album%,...,…),\.$,$noop(.))

Picard claims that there is an unexpected "." at position x which is the "\.$" portion. I tried replacing the "\." with "[.]" instead but that didn't work either as it claims that there is an unexpected "," at position y which is the ",$noop(.)" portion.

Any ideas?

Re: Repository for cool file naming parameter strings

The backslash and dollar sign are special character in tagger script and must be escaped, so $rreplace(%album%,\\.+\$,) should remove all trailing periods from the name.

I suggest moving further discussion to a separate thread, as this is rather off-topic here.

Re: Repository for cool file naming parameter strings

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.

Re: Repository for cool file naming parameter strings

UllicPendragon (and everyone else in this thread), thank you so much for sharing your code! This is a mod of the Single Artist File Naming Format code posted above by UllicPendragon.

For personal preference, when moving files, I wanted the folders named slightly differently than what was posted above:
1. I wanted the "Artist's Name" folder to be the first in the folder tree, and do away with the first-letter-of-the-artist's-name folder.
2. I didn't want the year to appear in the Album Name folder

Thus, I just deleted the parts of the code I didn't want, so all the credit for this code goes to UllicPendragon, and the only reason I'm posting this is just in case anyone else whose as clueless as I am wanted a copy/paste solution for this particular modification since this seemed to work for me.

$replace($if($eq($left($if2(%albumartist%,%artist%),4),The ),)/$rreplace($replace($if2(%albumartist%,%artist%),...,…),\\.\$,$noop(.))/$rreplace($replace(%album%,...,…),\\.\$,$noop(.))/$num(%tracknumber%,2) - $replace(%title%,...,…),_,$noop(.))

Example folder structure before:
[-=B=-]\The Beatles\[1965] Help!\07 - Ticket To Ride.mp3

Example folder structure after:
The Beatles\Help!\07 - Ticket To Ride.mp3

Hope it works!

Re: Repository for cool file naming parameter strings

Ha, sweet! You're welcome, rebel!

Re: Repository for cool file naming parameter strings

A friend asked me about adding the genre to the file naming format, so I did some web searches and tests.

You have to enable the “Use folksonomy tags as genre” option on the “Metadata” tab in the Picard Options window. That option does two things: 1) tells Picard to actually tag the files with the “folksonomy” tags in the MusicBrainz database. 2) tells Picard to use the folksonomy tags when moving/renaming files where %genre% appears. The folksonomy tagging system is like the tagging system used at Last.fm, where a single song can have multiple tags. When you use %genre% in Picard, it takes all of those tags and builds one string with all of the tags separated by semi-colons. For example, one I got was “Usa; Electronic; Disco-Punk; Dance-Punk; Dance And Electronica”.

If you have already tagged a bunch of folders with Picard, then they will need to be re-tagged by Picard in order to use genre, but the files will already be identified, so it’s no extra work for you. You will, however, see the asterisk in the Title column on the right-hand pane, indicating that Picard has some information the file doesn’t have, and that that information will be added to the file when you click “Save”.

One drawback of using %genre% is that many files don’t have tags in the MusicBrainz database (I know, we should all go in and add tags when we see that). If you simply put %genre%/ at the beginning of your file naming string, indicating that you want the first folder to be the genre, followed by sub-folders for artist name or whatever, Picard will use the tags for any files that have them, but for files that don’t have the tags, it will put the artist folder in the root folder along with all of the genre folders, so you will end up with folders like “Trip-Hop; Electronic” and “The Beatles” in the same root folder. I figure it would be preferable to have something like a “No Genre Information” folder for the files that don’t have tags. You can do that using Picard scripting; it looks like this: $if2(%genre%,No Genre Information)/


So, here are my modified file naming formats that include genre information:

File naming format:
$if2(%genre%,No Genre Information)/$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))/$if2(%albumartist%,%artist%)/$if(%date%,$left(%date%,4) -- )%album%/$num(%tracknumber%,2). %title%

Muliple artist file naming format:
$if2(%genre%,No Genre Information)/$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))/$if2(%albumartist%,%artist%)/$if(%date%,$left(%date%,4) -- )%album%/$num(%tracknumber%,2). %artist% - %title%


Here are the previews in Picard:

File name:
E:\Music\Picarded\No Genre Information\B\The Beatles\1965 -- Help!\07. Ticket to Ride.mp3
Multiple artist file name:
E:\Music\Picarded\No Genre Information\V\Various Artists\1999 -- Explosive Doowops, Volume 4\05. The Fantasys - Why  Oh Why .mp3


I don’t know what would happen with multiple artist albums. I haven’t tried tagging any.

19

Re: Repository for cool file naming parameter strings

My filenaming scripts. I only recently switched to picard, so they might not be quite perfect yet.

Single artist

$if2(%albumartist%,%artist%)/($if(%date%,$left(%date%,4),????)) - $if(%album%,%album%,Unknown)$set(labelstr,%label%)$if(%labelstr%,$if(%catalognumber%,$set(labelstr,%labelstr% )))$set(labelstr,%labelstr%%catalognumber%)$if(%labelstr%, {%labelstr%})$if(%discnumber%, \(Disc %discnumber%\),)/$num(%tracknumber%,2) - $if2(%albumartist%,%artist%) - %title%

Multiple artists:

$if2(%albumartist%,%artist%)/($if(%date%,$left(%date%,4),????)) - $if(%album%,%album%,Unknown)$set(labelstr,%label%)$if(%labelstr%,$if(%catalognumber%,$set(labelstr,%labelstr% )))$set(labelstr,%labelstr%%catalognumber%)$if(%labelstr%, {%labelstr%})$if(%discnumber%, \(Disc %discnumber%\),)/$num(%tracknumber%,2) - $if2(%artist%,%albumartist%) - %title%

Re: Repository for cool file naming parameter strings

Hello,
I'm trying to switch to picard from easytag.
Is there a way to convert: "The Beatles" to "Beatles, The" ?
Thanks

Re: Repository for cool file naming parameter strings

Use %artistsort% instead of %artist%.

Re: Repository for cool file naming parameter strings

voiceinsideyou wrote:

Use %artistsort% instead of %artist%.

I have this now:

$if2(%albumartist%,%artistsort%) - [$left(%date%,4)] %album%/$num(%tracknumber%,2) - %title%

But the preview still shows:
/Mp3/The Beatles - [1965] Help!/07 - Ticket to ride.mp3

I want it to look:
/Mp3/Beatles, The - [1965] Help!/07 - Ticket to ride.mp3

But I don't want "Cave, Nick" as said previously, only artists with "The".

Re: Repository for cool file naming parameter strings

Well, that string is definitely not correct. You'd also need to replace %albumartist% with %albumartistsort% as well.

Anyway you didn't /actually/ say anything about Nick Cave and only doing it for "The" artists previously. And please don't hijack other threads to ask for help.

It's unreadable to non-techies, but one way to do it is

$rreplace($if2(%albumartist%,%artist%),\(^The \)\(.*\),\\2\, The) - [$left(%date%,4)] %album%/$num(%tracknumber%,2) - %title%

Re: Repository for cool file naming parameter strings

ok, thanks!! that works.
and sorry for hijacking, I thought it was somehow related to this thread.

Re: Repository for cool file naming parameter strings

Here are the ones I use.

$if($eq(%_extension%,flac),music-archive,music)/$upper($left($if2(%albumartistsort%,%artistsort%),1))/$if2(%albumartistsort%,%artistsort%)/%album%/$num(%tracknumber%,2) - %artist% - %title%

$if($eq(%_extension%,flac),music-archive,music)/Various/$upper($left(%album%,1))/%album%/$num(%tracknumber%,2) - %artist% - %title%

I actually have 2 directories to store my music.  One is "music" for all lossy encoded files (mp3, ogg) and the other is "music-archive" for my flac files.

This yields:

music/A/Angry Samoans/Back From Samoa/03 - Angry Samoans - Lights Out.mp3

music/Various/A/American Hardcore_ The History of American Punk Rock 1980-1986/01 - Black Flag - Nervous Breakdown.mp3

and:

music-archive/A/Angry Samoans/Back From Samoa/03 - Angry Samoans - Lights Out.flac

music-archive/Various/A/American Hardcore_ The History of American Punk Rock 1980-1986/01 - Black Flag - Nervous Breakdown.flac