Repository for neat file name string patterns and tagger script snippets

Hello :slight_smile:

On the old forums, there was a post called Repository for cool file naming parameter strings. This thread contains a lot of neat file naming string patterns and tagger script snippets. This topic is meant to have the same function for this new forum. :slight_smile: A lot of the snippets in that other thread are outdated and may not work properly with recent versions of Picard, so Iā€™ve decided to not bring any over myself just now, but go ahead and post your own favourites (but also please note what version of Picard youā€™re using, for future reference ;)).

One thing to note: this forum supports syntax highlighting (thanks to work done by @outsidecontext :raised_hands:) so be sure to do something like

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

to get something like:

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

Note: Picardā€™s website also has some tagger script examples that you may find useful:
https://picard.musicbrainz.org/docs/scripting/

13 Likes

Great the syntax highlighting is online now :slight_smile: Now here is my renaming script, which is not so far away from the standard:

$if($is_video(),videos,music)/
$if($is_video(),
$noop(Video track)
$if($ne(%album%,[non-album tracks]),
$if2(%albumartist%,%artist%) - %album%$if(%discsubtitle%, - %discsubtitle%)/%_discandtracknumber%%title%,
Music Videos/%artist%/%artist% - %title%),
$if($eq(%compilation%,1),
$noop(Various Artist albums)
$firstalphachar($if2(%albumartistsort%,%artistsort%))/$if2(%albumartist%,%artist%)/%album%$if(%_releasecomment%, \(%_releasecomment%\),)/%_discandtracknumber%%artist% - %title%,
$noop(Single Artist Albums)
$firstalphachar($if2(%albumartistsort%,%artistsort%))/$if2(%albumartist%,%artist%)/%album%$if(%_releasecomment%, \(%_releasecomment%\),)/%_discandtracknumber%%title%
))

The special thing is that this also handles videos, which are stored separately from audio files, $is_video is part of the videotools plugin [1].

Here are some examples how this looks like for audio files.

Release by a single artist:

music/P/Paradise Lost/Say Just Words (silver version)/01-04 Say Just Words.flac

Compilation:

music/V/Various Artists/Century Media_ Covering 20 Years of Extremes/02-04 The Agonist - Monochromatic Stains.flac

For videos I use a more flat structure since I donā€™t have that many and also store them separately. I also distinguish between video releases (e.g. DVD) and just single videos.

Music video (from release):

videos/Paradise Lost - The Anatomy of Melancholy/01-12 As I Die.m4v

Music video (non-album track) [2]:

videos/Music Videos/Paradise Lost/Paradise Lost - Beneath Broken Earth.m4v

I also set some helper variables in Advanced -> Scripting:

$noop(
Helper variable to get the disc and track numbers in the from 01-12, unless it is a
non-album track. I always use the disc number in file names no matter if a release
has a single or multiple discs.
)
$set(_discandtracknumber,$if($ne(%album%,[non-album tracks]),$num(%discnumber%,2)-$num(%tracknumber%,2) ))

$noop(Remove "(promo video)" ETI from track titles)
$set(title,$replace(%title%, \(promo video\),))

  1. The videotools plugin is available on the Picard plugins page and provides some helper functions to ease working with videos in Picard. Unfortunately it does not work on Windows, I hope I will find some time to fix that.
  2. The redundancy of the artist name is intentional, that makes it easier to copy the file by itself without the entire structure.
2 Likes

I came across this post as i see it mentioned ā€œRepository for cool file naming parameter stringsā€, in which was a particular string i used to used that also grouped artists in a alphabetised list, rather than a folder overflowing with albums.

basic structure was .

for some time now that link has been unavailable and i have been unable to replicate; the script and organising my collection has come to an inglorious halt.

Do you perhaps know where that script info is alternatively housed (its not on the generic list provided by Music Brainz)

Thanks

Your organization is almost identical to mine! Here is what mine looks like:

And here is the script I have been using for years:

$replace($rreplace(
$if($eq(%albumartist%,Various Artists),
        [Various Artists],
	$left($if2(%albumartistsort%,%artistsort%),1)/$left($rreplace($if2(%albumartistsort%,%artistsort%),; [^\)]+,), 60))
/
$if(%date%,[$left(%date%,4)] )$left($replace(%album%,/,), 70)
$if($gt(%totaldiscs%,1),$if(%discnumber%, \(Disc %discnumber%\),),)
/
$num(%tracknumber%,2). $left(%title%,120),[:?"_]+,),  , )
3 Likes

Thanks @thebradleys, that looks like itā€™ll work!

1 Like

Let me see if I can figure out the formatting for this new forum for my rename string. Sadly this is not my latest from the old forum since the old forum seems to be permanently lost. But itā€™s fairly up to date, and if I find bugs Iā€™ll fix them.

One thing I want to add is a method to include special modifiers to the album folder name for things like [SACD] or [MFSL] (for Mobile Fidelity Sound Lab releases). but I might not have the time to get to this soon.

anyway, hereā€™s my script, it is similar to @thebradleys but while including the original release date to the beginning of the album folder I also include the release year for the specific edition (ie for special editions or things like MFSL releases). I also donā€™t organize by first letter (though Iā€™ve thought about adding it, all my playback software uses a library system that negates that need).

$noop(If %albumartist% != [Nothing] AND %albumartist% != various
artists -> _artist = %albumartist%)

$noop(If %albumartist% = [Nothing] OR %albumartist% = various artists
-> _artist = %artist%)


$noop($set(_artist,$if($and($ne(%albumartistsort%,),$ne($lower(%albumartistsort%),various
artists)),%albumartistsort%,%artistsort%)))


$set(_artist,$if($eq(%compilation%,1),%artist%,$if($ne(%artist%,),%artist%,%albumartist%)))


$set(_albumartist,$if($and($eq(%compilation%,1),$eq($lower(%albumartist%),various
artists)),!Various Artists,%albumartistsort%))


$noop(_________________________________________________)


$noop(If %_artistnamedelimiter% is in %_artist% -> _morethanoneartist = 1)

$noop(If %_artistnamedelimiter% is not in %_artist% -> _morethanoneartist = 0)

$noop(If there is more than one artist, we use the first only)


$set(_artistnamedelimiter,;)

$if($in(%_artist%,%_artistnamedelimiter%),$set(_morethanoneartist,1),$set(_morethanoneartist,0))

$if($eq(%_morethanoneartist%,1),$set(_artist,$rsearch(%_artist%,[^%_artistnamedelimiter%]+%_artistnamedelimiter%)),)

$if($eq(%_morethanoneartist%,1),$if($eq($right(%_artist%,1),%_artistnamedelimiter%),$set(_artist,$trim(%_artist%,%_artistnamedelimiter%)),),)


$noop(_________________________________________________)


$noop(Attention: Do not write parentheses in the Comment tag.)

$noop(Use "Comment=" to write normal comments, in English please.)

$noop(Separate your comments by "|".)


$noop(In the Comments, use "NonLatinArtistInEnglish=" to write the
English translation of an artist name typed with non-latin characters,
for instance russian of japanese.)

$noop(Use "NonLatinArtistInLatin=" to write with latin characters an
artist name typed with non-latin characters.)

$noop("NonLatinArtistInEnglish=" has priority over "NonLatinArtistInLatin=".)


$noop(In %comment:%, copies what is after %_nonlatinartistinenglish%
in _nonlatinartist)

$noop(If %_nonlatinartist% = [Nothing] -> copies what is after
%_nonlatinartistinlatin% in _nonlatinartist)

$noop(Deletes the content after the comment delimiter)

$noop(Deletes "NonLatinArtistInEnglish=" and "NonLatinArtistInLatin="
from the content)

$noop(If if the rightmost character is "|" or "_", we delete it)


$set(_commentdelimiter,|)

$set(_musicbrainzreplacementforwindowsforbiddencharacters,_)

$set(_nonlatinartistinenglish,NonLatinArtistInEnglish=)

$set(_nonlatinartistinlatin,NonLatinArtistInLatin=)

$set(_nonlatinartist,$rsearch(%comment:%,%_nonlatinartistinenglish%[^\(\)]+))

$if($eq(%_nonlatinartist%,),$set(_nonlatinartist,$rsearch(%comment:%,%_nonlatinartistinlatin%[^\(\)]+)),)

$set(_nonlatinartist,$rsearch(%_nonlatinartist%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_nonlatinartist,$rreplace(%_nonlatinartist%,^%_nonlatinartistinenglish%{1},))

$set(_nonlatinartist,$rreplace(%_nonlatinartist%,^%_nonlatinartistinlatin%{1},))

$if($eq($right(%_nonlatinartist%,1),%_commentdelimiter%),$set(_nonlatinartist,$trim(%_nonlatinartist%,%_commentdelimiter%)),)

$if($eq($right(%_nonlatinartist%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_nonlatinartist,$trim(%_nonlatinartist%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(In the Comments, use "ArtistCommentInEnglish=" to write to write
a comment on the artist.)


$set(_artistcommentinenglish,ArtistCommentInEnglish=)

$set(_artistcomment,$rsearch(%comment:%,%_artistcommentinenglish%[^\(\)]+))

$set(_artistcomment,$rsearch(%_artistcomment%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_artistcomment,$rreplace(%_artistcomment%,^%_artistcommentinenglish%{1},))

$if($eq($right(%_artistcomment%,1),%_commentdelimiter%),$set(_artistcomment,$trim(%_artistcomment%,%_commentdelimiter%)),)

$if($eq($right(%_artistcomment%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_artistcomment,$trim(%_artistcomment%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(Integrates the content of _nonlatinartist and _artistcomment in _artist)


$set(_artist,%_artist%$if($ne(%_nonlatinartist%,),
\(%_nonlatinartist%\),)$if($ne(%_artistcomment%,),
\(%_artistcomment%\),))


$noop(_________________________________________________)


$noop(Prefer %originaldate% to %date% for sorting)

$set(_date,$if2(%originaldate%,%date%))


$noop(Prefer just year)

$set(_date,$if($or(%originaldate%,%date%),[$left(%_date%,4)] ,))


$noop(_________________________________________________)


$noop(In the Comments, use "NonLatinAlbumInEnglish=" to write the
English translation of an album name typed with non-latin characters.)

$noop(Use "NonLatinAlbumInLatin=" to write with latin characters an
album name typed with non-latin characters.)

$noop("NonLatinAlbumInEnglish=" has priority over "NonLatinAlbumInLatin=".)


$set(_nonlatinalbuminenglish,NonLatinAlbumInEnglish=)

$set(_nonlatinalbuminlatin,NonLatinAlbumInLatin=)

$set(_nonlatinalbum,$rsearch(%comment:%,%_nonlatinalbuminenglish%[^\(\)]+))

$if($eq(%_nonlatinalbum%,),$set(_nonlatinalbum,$rsearch(%comment:%,%_nonlatinalbuminlatin%[^\(\)]+)),)

$set(_nonlatinalbum,$rsearch(%_nonlatinalbum%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_nonlatinalbum,$rreplace(%_nonlatinalbum%,^%_nonlatinalbuminenglish%{1},))

$set(_nonlatinalbum,$rreplace(%_nonlatinalbum%,^%_nonlatinalbuminlatin%{1},))

$if($eq($right(%_nonlatinalbum%,1),%_commentdelimiter%),$set(_nonlatinalbum,$trim(%_nonlatinalbum%,%_commentdelimiter%)),)

$if($eq($right(%_nonlatinalbum%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_nonlatinalbum,$trim(%_nonlatinalbum%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(In the Comments, use "AlbumCommentInEnglish=" to write to write
a comment on the album.)


$set(_albumcommentinenglish,AlbumCommentInEnglish=)

$set(_albumcomment,$rsearch(%comment:%,%_albumcommentinenglish%[^\(\)]+))

$set(_albumcomment,$rsearch(%_albumcomment%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_albumcomment,$rreplace(%_albumcomment%,^%_albumcommentinenglish%{1},))

$if($eq($right(%_albumcomment%,1),%_commentdelimiter%),$set(_albumcomment,$trim(%_albumcomment%,%_commentdelimiter%)),)

$if($eq($right(%_albumcomment%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_albumcomment,$trim(%_albumcomment%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(Integrates the content of _nonlatinartist and _albumcomment in _album)


$noop($set(_album,%album%$if($gt(%totaldiscs%,1), \(Disc
%discnumber%$if($ne(%discsubtitle%,), -
%discsubtitle%\),\)$if($ne(%_nonlatinalbum%,),
\(%_nonlatinalbum%\),)$if($ne(%_albumcomment%,),
\(%_albumcomment%\),)),$if($ne(%_nonlatinalbum%,),
\(%_nonlatinalbum%\),)$if($ne(%_albumcomment%,),
\(%_albumcomment%\),))))


$set(_album,$if($and(%originaldate%,%date%),$if($eq($left(%originaldate%,4),$left(%date%,4)),%album%,%album%
 [$left(%date%,4)]),%album%))



$noop(_________________________________________________)


$noop(If %totaldiscs% > 1 = If there is more than one disc, write
"Disc ? - [Disc subtitle])

$noop(handle disc content separately)


$set(_discalbum,

$if(

$gt(%totaldiscs%,1),

Disc %discnumber%

$if($ne(%discsubtitle%,), - %discsubtitle%

,

$if($ne(%_nonlatinalbum%,), %_nonlatinalbum%,)

$if($ne(%_albumcomment%,), %_albumcomment%,)

),$if($ne(%_nonlatinalbum%,), %_nonlatinalbum%,)

$if($ne(%_albumcomment%,), %_albumcomment%,)

)

)


$set(_discnumber,

$if(

$gt(%totaldiscs%,1),

%discnumber%-,

)

)


$set(_discname,

$if(

$gt(%totaldiscs%,1),

$if($ne(%discsubtitle%,), %discsubtitle%

,

$if($ne(%_nonlatinalbum%,),%_nonlatinalbum%,)

$if($ne(%_albumcomment%,),%_albumcomment%,)

),$if($ne(%_nonlatinalbum%,),%_nonlatinalbum%,)

$if($ne(%_albumcomment%,),%_albumcomment%,)

)

)


$set(_vardiscname,

$if(

$gt(%totaldiscs%,1),

$if($ne(%discsubtitle%,), - %discsubtitle%,

$if($ne(%_nonlatinalbum%,), - %_nonlatinalbum%,)

$if($ne(%_albumcomment%,), - %_albumcomment%,)

),$if($ne(%_nonlatinalbum%,), - %_nonlatinalbum%,)

$if($ne(%_albumcomment%,), - %_albumcomment%,)

)

)

$noop(_________________________________________________)


$noop(If there is no track = If %album% = [non-album tracks] OR
%tracknumber% = 0 OR %tracknumber% = [Nothing] -> _notrack = 1)

$noop(If _notrack = 1 -> _tracknumber = 0)

$noop(If _notrack = 0 -> _tracknumber = %tracknumber% with no 0 digit at left)


$set(_notrack,$if($if2($eq(%album%,[non-album
tracks]),$eq(%tracknumber%,0),$eq(%tracknumber%,)),1,0))

$noop($set(_tracknumber,$if($eq(%_notrack%,0),$num(%tracknumber%,2),0)))


$set(_tracknumber,$if($eq(%_notrack%,0),$if($gt(%totaldiscs%,1),%discnumber%-)$if($gt(%tracknumber%,99),$num(%tracknumber%,3),$num(%tracknumber%,2)),0))


$noop(_________________________________________________)


$noop(In the Comments, use "NonLatinTitleInEnglish=" to write the
English translation of a title name typed with non-latin characters.)

$noop(Use "NonLatinTitleInLatin=" to write with latin characters an
album name typed with non-latin characters.)

$noop("NonLatinTitleInEnglish=" has priority over "NonLatinTitleInLatin=".)


$set(_nonlatintitleinenglish,NonLatinTitleInEnglish=)

$set(_nonlatintitleinlatin,NonLatinTitleInLatin=)

$set(_nonlatintitle,$rsearch(%comment:%,%_nonlatintitleinenglish%[^\(\)]+))

$if($eq(%_nonlatintitle%,),$set(_nonlatintitle,$rsearch(%comment:%,%_nonlatintitleinlatin%[^\(\)]+)),)

$set(_nonlatintitle,$rsearch(%_nonlatintitle%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_nonlatintitle,$rreplace(%_nonlatintitle%,^%_nonlatintitleinenglish%{1},))

$set(_nonlatintitle,$rreplace(%_nonlatintitle%,^%_nonlatintitleinlatin%{1},))

$if($eq($right(%_nonlatintitle%,1),%_commentdelimiter%),$set(_nonlatintitle,$trim(%_nonlatintitle%,%_commentdelimiter%)),)

$if($eq($right(%_nonlatintitle%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_nonlatintitle,$trim(%_nonlatintitle%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(In the Comments, use "TitleCommentInEnglish=" to write to write
a comment on the title.)


$set(_titlecommentinenglish,TitleCommentInEnglish=)

$set(_titlecomment,$rsearch(%comment:%,%_titlecommentinenglish%[^\(\)]+))

$set(_titlecomment,$rsearch(%_titlecomment%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_titlecomment,$rreplace(%_titlecomment%,^%_titlecommentinenglish%{1},))

$if($eq($right(%_titlecomment%,1),%_commentdelimiter%),$set(_titlecomment,$trim(%_titlecomment%,%_commentdelimiter%)),)

$if($eq($right(%_titlecomment%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_titlecomment,$trim(%_titlecomment%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(Integrates the content of _nonlatintitle and _titlecomment in _title)


$set(_title,%title%$if($ne(%_nonlatintitle%,),
\(%_nonlatintitle%\),)$if($ne(%_titlecomment%,),
\(%_titlecomment%\),))


$noop(_________________________________________________)


$noop(In the Comments, use "FirstPartOfTheName=" to write something on
the left, in the first position)


$set(_firstpartofthename,FirstPartOfTheName=)

$set(_filenameprefix,$rsearch(%comment:%,%_firstpartofthename%[^\(\)]+))

$set(_filenameprefix,$rsearch(%_filenameprefix%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_filenameprefix,$rreplace(%_filenameprefix%,^%_firstpartofthename%{1},))

$if($eq($right(%_filenameprefix%,1),%_commentdelimiter%),$set(_filenameprefix,$trim(%_filenameprefix%,%_commentdelimiter%)),)

$if($eq($right(%_filenameprefix%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_filenameprefix,$trim(%_filenameprefix%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(In the Comments, use "LastPartOfTheName=" to write something on
the right, in the last position)


$set(_lastpartofthename,LastPartOfTheName=)

$set(_filenamesuffix,$rsearch(%comment:%,%_lastpartofthename%[^\(\)]+))

$set(_filenamesuffix,$rsearch(%_filenamesuffix%,[^%_commentdelimiter%]+%_commentdelimiter%))

$set(_filenamesuffix,$rreplace(%_filenamesuffix%,^%_lastpartofthename%{1},))

$if($eq($right(%_filenamesuffix%,1),%_commentdelimiter%),$set(_filenamesuffix,$trim(%_filenamesuffix%,%_commentdelimiter%)),)

$if($eq($right(%_filenamesuffix%,1),%_musicbrainzreplacementforwindowsforbiddencharacters%),$set(_filenamesuffix,$trim(%_filenamesuffix%,%_musicbrainzreplacementforwindowsforbiddencharacters%)),)


$noop(_________________________________________________)


$noop(Windows limits file fullname to 255 characters.)

$noop(So We set a limit for each part to 85 characters.)

$noop(If the length of a part is longer than than, we truncate with "[ā€¦]".)


$set(_maximumlength,85)

$set(_toolongmarker,[ā€¦])

$if($gte($len(%_artist%),%_maximumlength%),$set(_artist,$firstwords(%_artist%,%_maximumlength%)%_toolongmarker%),)

$if($gte($len(%_album%),%_maximumlength%),$set(_album,$firstwords(%_album%,%_maximumlength%)%_toolongmarker%),)

$if($gte($len(%_title%),%_maximumlength%),$set(_title,$firstwords(%_title%,%_maximumlength%)%_toolongmarker%),)


$noop(_________________________________________________)

$noop(Output Track Name)

$noop(_________________________________________________)


$set(_trackname,$if($ne(%_filenameprefix%,),%_filenameprefix% -
,)$if($eq(%compilation%,1),%_albumartist%////%_date%
%_album%////%_tracknumber%%_vardiscname% - %_artist% -
%_title%,$if(%albumartistsort%,%albumartistsort%,%artistsort%)////%_date%
%_album%////%_tracknumber% -
%_discname%%_title%)$if($ne(%_filenamesuffix%,), -
%_filenamesuffix%,))



$noop(_________________________________________________)


$noop(Replaces Windows forbidden characters by Unicode equivalent ? ?
: * ? ā€ ā€¹ ā€ŗ |)

$noop(On Windows, MusicBrainz just deletes slash and anti-slash before
everything by security.)


$set(_windowsforbiddencharacterantislash,\\\\)

$set(_windowsforbiddencharacterfolderslash,////)

$set(_windowsforbiddencharacterslash,/)

$set(_windowsforbiddencharactercolon,:)

$set(_windowsforbiddencharacterasterisk,*)

$set(_windowsforbiddencharacterquestionmark,?)

$set(_windowsforbiddencharacterquotationmark,")

$set(_windowsforbiddencharacterlessthansign,<)

$set(_windowsforbiddencharactergreaterthansign,>)

$set(_windowsforbiddencharacterverticalbar,|)


$set(_windowsunicodeequivalentantislash,?)

$set(_windowsunicodeequivalentfolderslash,/)

$set(_windowsunicodeequivalentslash,?)

$set(_windowsunicodeequivalentcolon,:)

$set(_windowsunicodeequivalentasterisk,*)

$set(_windowsunicodeequivalentquestionmark,?)

$set(_windowsunicodeequivalentquotationmark,ā€)

$set(_windowsunicodeequivalentlessthansign,ā€¹)

$set(_windowsunicodeequivalentgreaterthansign,ā€ŗ)

$set(_windowsunicodeequivalentverticalbar,|)


$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterantislash%]+,%_windowsunicodeequivalentantislash%))

$noop($set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterslash%]+,%_windowsunicodeequivalentslash%)))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterfolderslash%]+,%_windowsunicodeequivalentfolderslash%))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharactercolon%]+,%_windowsunicodeequivalentcolon%))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterasterisk%]+,%_windowsunicodeequivalentasterisk%))

$noop($set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterquestionmark%]+,%_windowsunicodeequivalentquestionmark%)))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterquotationmark%]+,%_windowsunicodeequivalentquotationmark%))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterlessthansign%]+,%_windowsunicodeequivalentlessthansign%))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharactergreaterthansign%]+,%_windowsunicodeequivalentgreaterthansign%))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharacterverticalbar%]+,%_windowsunicodeequivalentverticalbar%))


$noop(_________________________________________________)


$noop(UNIX hides files beginning by "." and MusicBrainz replaces it by
"_" so we replace it by "Ā·")

$noop(Replaces "..." by "ā€¦" too)


$set(_unixforbiddencharacterellipsis,...)

$set(_unixforbiddencharacterfullstop,.)


$set(_unixunicodeequivalentellipsis,ā€¦)

$set(_unixunicodeequivalentfullstop,Ā·)


$set(_trackname,$if($eq($left(%_trackname%,3),%_unixforbiddencharacterellipsis%),$rreplace(%_trackname%,^%_unixforbiddencharacterfullstop%{3},%_unixunicodeequivalentellipsis%),%_trackname%))

$set(_trackname,$if($eq($left(%_trackname%,1),%_unixforbiddencharacterfullstop%),$rreplace(%_trackname%,^%_unixforbiddencharacterfullstop%{1},%_unixunicodeequivalentfullstop%),%_trackname%))


$noop(_________________________________________________)


$noop(MusicBrainz replaces these forbidden characters by underscore _,
we delete them)


$set(_trackname,$rreplace(%_trackname%,[%_musicbrainzreplacementforwindowsforbiddencharacters%]+,))


$noop(_________________________________________________)


$noop(Replaces other characters by space: Tab, Carriage return)


$set(_windowsforbiddencharactertabulator,\\t)

$set(_windowsforbiddencharactercarriagereturn,\\n)


$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharactertabulator%]+,))

$set(_trackname,$rreplace(%_trackname%,[%_windowsforbiddencharactercarriagereturn%]+,))


$noop(_________________________________________________)


$noop(Replaces non-breaking space and other spaces by a simple space)


$set(_characterforspace,\\s)

$set(_trackname,$rreplace(%_trackname%,[%_characterforspace%]+, ))


$noop(_________________________________________________)


%_trackname%
1 Like

EDIT 2016-11-02: Updated to version 0.0.4Ī±. Also, if anyone uses Notepad++, I have a fairly good definition of the Picard Tagger Script language, posted below.


Hereā€™s my first attempt at a naming script. You just maybe might be able to guess that Iā€™m a software professional. :wink: But Iā€™m new to this level of detail in this language. (I donā€™t even know what the language is called or where itā€™s documented, although Iā€™ve specified file and folder names with it in other tagging apps.)

I want to learn how to create functions to get rid of all the repeated code and to create my own unique functions. And if thereā€™s documentation beyond the Scripting page on the Picard site Iā€™d love to know where it is.

Anyway, if you see anything you like or you think could be improved, donā€™t hesitate to comment.

Pardon the formatting - itā€™s copied from the text editor Iā€™m using, with tabs replaced by spaces for display here. This was written for Picard v1.3.2, my first Picard. No guarantees that it works with earlier versions.

$noop(MusicBrainz Picard file naming script.

   Author: Michael Piz [Your intrepid author {YIA}; @Piz on MusicBrainz]
   Version 0.0.4Ī± [2016-11-01, edit history at end]

   Copyright 2016 by Michael Pizolato. This work is licensed under a Creative
   Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
   Details are available at http://creativecommons.org/licenses/by-nc-sa/4.0/
   
   THIS IS AN ALPHA RELEASE!
   USE AT YOUR OWN RISK!

   YIA has a very specific naming convention for files and folders because, 
   while he's a genial fellow, he does have minor OCD tendencies. Here's what 
   this script generates for the examples in Picard's options [as of v1.3.2; 
   the line breaks are for display formatting only]: 
   
   ROOT/Beatles, The/Help! [soundtrack]/Beatles, The ā€¢ Help! [soundtrack] ā€¢ 
   07 Ā· Ticket to Ride.mp3

   ROOT/Various Artists/Coup d'Ɖtat, Volume 1 - Ku De 
   Ta - Prologue/Snowboy Ā· Various Artists ā€¢ Coup d'Ɖtat, Volume 1 - Ku De 
   Ta - Prologue ā€¢ 02.05 Ā· I've Got to Learn the Mambo.mp3 

   Here are some from YIA's own library:

   ROOT/Wings/Wings over America/Wings ā€¢ Wings over America ā€¢ 02.11 Ā· Band on 
   the Run [live].mp3 
   
   ROOT/Saint-Saƫns, Camille/Saint-Saƫns - Piano Concertos 1-5; Wedding Cake 
   Caprice-Valse/Saint-SaĆ«ns, Camille ā€¢ Saint-SaĆ«ns - Piano Concertos 1-5; 
   Wedding Cake Caprice-Valse ā€¢ 02.08 Ā· 'Africa' Fantaisie, Op. 89
   
   Broken down, they look like this:

   ARTIST FOLDER: Beatles, The
    ALBUM FOLDER: Help! [soundtrack]
      TRACK FILE: Beatles, The ā€¢ Help! [soundtrack] ā€¢ Track 07 Ā· Ticket to 
                  Ride.mp3

   ARTIST FOLDER: Various Artists
    ALBUM FOLDER: Coup d'Ɖtat, Volume 1 - Ku De Ta - Prologue
      TRACK FILE: Snowboy Ā· Various Artists ā€¢ Coup d'Ɖtat, Volume 1 - Ku De
                  Ta - Prologue ā€¢ Disc 02 Ā· Track 05 Ā· I've Got to Learn the
                  Mambo.mp3

   ARTIST FOLDER: Wings
    ALBUM FOLDER: Wings over America
      TRACK FILE: Wings ā€¢ Wings over America ā€¢ 02.11 Ā· Band on the Run [live]

   ARTIST FOLDER: Saint-Saƫns, Camille
    ALBUM FOLDER: Saint-Saƫns - Piano Concertos 1-5; Wedding Cake Caprice-Valse
      TRACK FILE: Saint-SaĆ«ns, Camille ā€¢ Saint-SaĆ«ns - Piano Concertos 1-5; 
                  Wedding Cake Caprice-Valse ā€¢ 02.08 Ā· 'Africa' Fantaisie, Op. 
                  89.mp3

   Track filenames duplicate all the folder information because in most UI 
   file search r only the filename of a match is displayed. This way, 
   all the infomation will be in the search results, resulting in unique 
   matches. YIA tends to be impatient, especially with looking things up more 
   than once.

   Here are examples of artist folders:
   
   [Various Artists]
   [unknown artist]
   10,000 Maniacs
   Beatles, The
   Davis, Sammy, Jr
   
   In addition to individual album folders within those, there can be 
   "[unknown album]" and "[singles]" folders. Within any of these, individual 
   track files are stored. In the "[Various Artists]" folder there are 
   individual album folders [and possibly "[unknown album]"]. Track names in 
   the "[Various Artists]" album folders include the form "Artist Ā· Various 
   Artists" so the individual artist is included. Tracks missing a title have 
   "unknown title" assigned as the title. Thus, should all fail, the 
   following is possible [though somewhat unlikely]:
   
   [unknown artist]/[unknown album]/[unknown artist] ā€¢ [unknown album] ā€¢ 
   [unknown title].mp3
   
   The brackets are added so those folders sort to the top of an ascending 
   alphabetical list [in Windows, anyway] instead of being mixed in with the  
   individual artist or album folders.
   
   Final note: You may wonder why YIA has created all these verbose constants 
   instead of just using their [shorter, duh] corresponding characters or 
   strings. That's because he doesn't trust himself not to drop extraneous 
   characters in this language. This language works by building a string from 
   the results of all the functions used plus, importantly, any explicit 
   characters in the script. For example, if you put "xyzzy" at the end of 
   your script, just literally like that, whatever final string you generate 
   will end in "xyzzy" even though it's not generated by a function call, and 
   no error will be displayed because that's how the language works. [If you 
   are insane and want to name all your files "foobar", your script can 
   consist solely of that string.] Stray spaces or punctuation or whatnot 
   strewn hither and yon could affect the final string in very difficult to 
   debug ways. Therefore, YIA, being completely untrusting of himself in such 
   matters, doesn't allow himself the possibility of strays. By using 
   variables as constants and never including whitespace in function calls 
   [except at the beginning of lines, where it is ignored], the possibility of 
   stray character gremlins is all but eliminated. [In addition, using 
   "_kNull" makes it explicit where null strings are used, also making 
   debugging, and reading the code, easier.]
   )

$noop(Basic constants.)
   $set(_kNull,)
   $set(_kSpace, )
   $set(_kComma,\,)
   $set(_kSingleQuote,')
   $set(_kEllipsis,ā€¦)
   $set(_kPeriod,.)
   $set(_kAmpersand, & )
   $set(_kNoteBracketLeft,[)
   $set(_kNoteBracketRight,])
$noop(End basic constants.)

$noop(Aticles.)
   $set(_kA,A)
   $set(_kAn,An)
   $set(_kThe,The)
$noop(End articles.)

$noop(Folder and track name constants.)
   $set(_kFolderSep,/)
   $noop(
      There are three levels of separators within track names. The top levels 
      are "Artist ā€¢ Album ā€¢ Track", corresponding to "Artist/Album/Track" in 
      the file system. In track names, for example when the album artist is 
      "Various Artists", one of the possible second levels is "Artist Ā· 
      Various Artists" [see the Snowboy and Saint-Saƫns examples above; also 
      note that the first and second level separators are different 
      characters, i.e. U+2022: Bullet and U+00B7: Middle Dot; the third level 
      separartor is U+002D: Hyphen-Minus, the simple minus sign]. The third 
      level separator replaces any characters in artist/album/track names that 
      are illegal filename characters, e.g. "Some Band: Greatest Hits" becomes 
      "Some Band - Greatest Hits" [again, see the Snowboy and Saint-Saƫns 
      examples].
      )
      $set(_kTrackSep1, ā€¢ )
      $set(_kTrackSep2, Ā· )
      $set(_kTrackSep3, - )
$noop(End folder and track name constants.)

$noop(Filename substitution regex constants.)
   $noop(All bracket types.)
      $set(_kReOpenBrackets,[\\%_kNoteBracketLeft%\({])
      $set(_kReCloseBrackets,[\\%_kNoteBracketRight%\){])
   $noop(For replacing three consecutive periods with one ellipsis.)
      $set(_kRe3Dots,\\%_kPeriod%\\%_kPeriod%\\%_kPeriod%)
   $noop(Trim all multiple spaces down to single spaces.)
      $set(_kMultiSpace,\\s+)
   $noop(
      Remove characters not permitted in file or folder names. These are
      treated as separators and replaced with _kTrackSep2. Underscore isn't
      really an illegal char but having it here gets it replaced by a
      separator.
      )
      $set(_kReIllegalFileChars,\\s*[/\\><*:_|]+\\s*)
   $noop(
      Replace all quote marks with single quotes. The double quote isn't part
      of the illegal chars because those get dropped, not replaced.
      )
      $set(_kReQuoteMarks,["ā€œā€ā€˜ā€™]+)
   $noop(
      Remove question marks entirely. E.g., "What Kind of Fool Am I?" becomes
      "What Kind of Fool Am I". This isn't part of the illegal chars because
      those get dropped, not replaced. The inverted question mark is dropped
      for aesthetic reasons - it won't have its mate.
      )
      $set(_kReQuestionMarks,[Āæ?]+)
   $noop(
      Windows doesn't allow periods as the final char of folder names. It 
      automatically drops them in Windows Explorer, but YIA doesn't know what 
      happens programatically so it's best to drop them here.
      )
      $set(_kReEndPeriod,\\.\$)
   $noop(Case insensitivity.)
      $set(_kReCaseInsensitive,\(?i\))
   $noop(And. Always replace wth '&'.)
      $set(_kReAnd,%_kReCaseInsensitive%\\sand\\s)
   $noop(
      Remove "feat." or "ft." [with or without the periods] plus everything 
      that follows [and precedes, if inside brackets].
      )
      $set(_kReFeat,
         \\s+\(%_kReOpenBrackets%.*\)?f\(ea\)?t\\.?.*\(%_kReCloseBrackets%.*\)?
         )
$noop(End filename substitution regex constants.)

$noop(Artist/album/title/media/track constants.)
   $noop(
      Release types. Comment shows whether value goes in album or track 
      notes. Album and single determine the others. "Other" isn't used 
      because it provides no information.
      )
      $set(_kAlbum,album)           $noop(N/A)
      $set(_kSingle,single)         $noop(N/A)
      $set(_kEP,ep)                 $noop(album)
      $set(_kBroadcast,broadcast)   $noop(track)
      $set(_kOther,other)           $noop(N/A)
   $noop(
      Secondary release types. Comment shows whether value goes in album 
      or track notes.
      )
      $set(_kCompilation,compilation)  $noop(album)
      $set(_kSoundtrack,soundtrack)    $noop(album)
      $set(_kAudiobook,audiobook)      $noop(album)
      $set(_kMixtape,mixtape/street)   $noop(album)
      $set(_kSpokenword,spokenword)    $noop(track)
      $set(_kInterview,interview)      $noop(track)
      $set(_kLive,live)                $noop(track)
      $set(_kRemix,remix)              $noop(track)
      $set(_kDJMix,dj-mix)             $noop(track)
   $noop(Default artist/album/title.)
      $set(_kUnknownArtist,unknown artist)
      $set(_kUnknownAlbum,unknown album)
      $set(_kNoTitle,unknown title)
   $noop(
      NOTE: The next two must duplicate the "Various artists" and "Non-album
      tracks" option settings. I've submitted a Picard feature request to
      have those options be made available as tags, to avoid having to
      maintain them in two places. That ticket can be found at 
      https://tickets.musicbrainz.org/browse/PICARD-849
      )
      $set(_kVariousArtists,Various Artists)
      $set(_kNonAlbumTracks,%_kNoteBracketLeft%singles%_kNoteBracketRight%)
   $noop(Media and track number.)
      $set(_kDefaultMedia,Disc)
      $set(_kTrackTxt,Track )
$noop(End artist/album/title/media/track constants.)

$noop(Copies of existing tags.

   After this, only the copies are used. In some instances, the tag is later
   replaced by the processed copy.
   )
   $set(_media,%media%)
   $set(_totaldiscs,%totaldiscs%)
   $set(_discNum,%discnumber%)
   $set(_trackNum,%tracknumber%)
   $noop(Album, artist, album artist, and title are more complex.)
      $set(_artist,
         $if2(
            %artistsort%,
            %artist%,
            %albumartistsort%,
            %albumartist%,
            %_kUnknownArtist%
            )
         )
      $set(_albumArtist,
         $noop(albumartistsort already handles "A" and The")
         $swapprefix(
            $if2(%albumartistsort%,
               %albumartist%,
               %artistsort%,
               %artist%,
               %_kUnknownArtist%
               ),
            %_kAn%
            )
         )
      $set(_album,
         $swapprefix(
            $if2(%album%,%_kUnknownAlbum%),
            %_kA%,%_kAn%,%_kThe%
            )
         )
      $set(_title,
         $swapprefix(
            $if2(%title%,%_kNoTitle%),
            %_kA%,%_kAn%,%_kThe%
            )
         )
$noop(End copies of existing tags.)

$noop(Album/artist/track characteristics.)
   $set(_isVariousArtists,$eq(%albumartist%,%_kVariousArtists%))
   $set(_differentAlbumArtist,$ne(%artistsort%,%albumartistsort%))
   $set(_isUnknownArtist,
      $or($not(%albumartist%),$eq(%albumartist%,%_kUnknownArtist%))
      )
   $set(_isUnknownAlbum,
      $or($not(%album%),$eq(%album%,%_kUnknownAlbum%))
      )
   $set(_isSingle,$in(%releasetype%,%_kSingle%))
$noop(End track characteristics.)

$noop(Album/track notes.)
   $set(_relType,%_kSoundtrack%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_albumNotes,
         %_albumNotes%$if(%_albumNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kAudiobook%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_albumNotes,
         %_albumNotes%$if(%_albumNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kMixtape%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_albumNotes,
         %_albumNotes%$if(%_albumNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kCompilation%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($not(%_isVariousArtists%)
      $if($rsearch(%_secondaryreleasetype%,%_pattern%),
         $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
         $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
         $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
         $set(_albumNotes,
            %_albumNotes%$if(%_albumNotes%,%_kComma%%_kSpace%)%_relType%
            )
         ),
      %_kNull%
      )
   $set(_relType,%_kEP%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%releasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_albumNotes,
         %_albumNotes%$if(%_albumNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kLive%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kBroadcast%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%releasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         ),
      )
   $set(_relType,%_kSpokenword%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kInterview%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kRemix%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $set(_relType,%_kDJMix%)
   $set(_pattern,
      %_kReCaseInsensitive%\(%_kReOpenBrackets%?%_relType%%_kReCloseBrackets%?\)
      )
   $if($rsearch(%_secondaryreleasetype%,%_pattern%),
      $set(_artist,$rreplace(%_artist%,%_pattern%,%_kNull%))
      $set(_album,$rreplace(%_album%,%_pattern%,%_kNull%))
      $set(_title,$rreplace(%_title%,%_pattern%,%_kNull%))
      $set(_trackNotes,
         %_trackNotes%$if(%_trackNotes%,%_kComma%%_kSpace%)%_relType%
         )
      )
   $if(%_albumNotes%,
      $set(_albumNotes,
         %_kSpace%%_kNoteBracketLeft%%_albumNotes%%_kNoteBracketRight%
         )
      )
   $if(%_trackNotes%,
      $set(_trackNotes,
         %_kSpace%%_kNoteBracketLeft%%_trackNotes%%_kNoteBracketRight%
         )
      )
$noop(End album/track notes.)

$noop(Set up file/folder names.)
   $noop(Artist. Only used for the track filename.)
      $set(_artist,$rreplace($rreplace($rreplace($rreplace(%_artist%,
         %_kReFeat%,%_kNull%),
         %_kMultiSpace%,%_kSpace%),
         %_kRe3Dots%,%_kEllipsis%),
         %_kReAnd%,%_kAmpersand%)
         )
      $noop(
         At this point the artist to be used for tagging is "clean", so set
         the actual tag value. Similarly for album artist and album, below.
         )
         $set(artist,%_artist%)
      $noop(Scrub _artist for file names.)
         $set(_artist,$rreplace($rreplace($rreplace(%_artist%,
            %_kReQuestionMarks%,%_kNull%),
            %_kReQuoteMarks%,%_kSingleQuote%),
            %_kReIllegalFileChars%,%_kTrackSep3%)
            )
      $noop(Make the filename part.)
         $set(_artistTrack,
            %_artist%
            $if(%_differentAlbumArtist%,
               %_kTrackSep2%,
               %_kTrackSep1%
               )
            )
   $noop(End artist.)

   $noop(Album artist.)
      $set(_albumArtist,$rreplace($rreplace($rreplace($rreplace(%_albumArtist%,
         %_kReFeat%,%_kNull%),
         %_kMultiSpace%,%_kSpace%),
         %_kRe3Dots%,%_kEllipsis%),
         %_kReAnd%,%_kAmpersand%)
         )
      $set(albumartist,%_albumArtist%)
      $set(_albumArtist,$rreplace($rreplace($rreplace(%_albumArtist%,
         %_kReQuestionMarks%,%_kNull%),
         %_kReQuoteMarks%,%_kSingleQuote%),
         %_kReIllegalFileChars%,%_kTrackSep3%)
         )
      $set(_albumArtist,$rreplace(%_albumArtist%,%_kReEndPeriod%,%_kNull%))
      $if(%_differentAlbumArtist%,
         $noop(_albumArtistTrack is unnecesasry when they match.)
         $set(_albumArtistTrack,
            $if(%_isUnknownArtist%,
               %_kNoteBracketLeft%%_albumArtist%%_kNoteBracketRight%,
               %_albumArtist%
               )
               %_kTrackSep1%
            )
         )
      $set(_albumArtistFolder,
         $if($or(%_isVariousArtists%,%_isUnknownArtist%),
            %_kNoteBracketLeft%%_albumArtist%%_kNoteBracketRight%,
            %_albumArtist%
            )
            %_kFolderSep%
         )
   $noop(End album artist.)

   $noop(Album.)
      $set(_album,$rreplace($rreplace($rreplace($rreplace(%_album%,
         %_kReFeat%,%_kNull%),
         %_kMultiSpace%,%_kSpace%),
         %_kRe3Dots%,%_kEllipsis%),
         %_kReAnd%,%_kAmpersand%)
         )
      $set(_album,%_album%%_albumNotes%)
      $set(album,%_album%)
      $set(_album,$rreplace($rreplace($rreplace(%_album%,
         %_kReQuestionMarks%,%_kNull%),
         %_kReQuoteMarks%,%_kSingleQuote%),
         %_kReIllegalFileChars%,%_kTrackSep3%)
         )
      $set(_album,$rreplace(%_album%,%_kReEndPeriod%,%_kNull%))
      $set(_albumTrack,$if($not(%_isSingle%),%_album%%_kTrackSep1%))
      $set(_albumFolder,
         $if(%_isUnknownAlbum%,
            %_kNoteBracketLeft%%_album%%_kNoteBracketRight%,
            %_album%
            )
            %_kFolderSep%
         )
   $noop(End album.)

   $noop(Media type.)
      $set(_media,$if2(%_media%,%_kDefaultMedia%)%_kSpace%)
   $noop(End media type.)

   $noop(Disc number, if necessary.)
      $set(_discNum,
         $if($gt(%_totaldiscs%,1),
            $num(%_discNum%,2)%_kPeriod%,
            %_kNull%
            )
         )
   $noop(End end disc number. )

   $noop(Track number.)
   $set(_trackNum,
      $if($and(
            %_trackNum%,
            $or($not(%_isSingle%),$ne(%_album%,%_kNonAlbumTracks%))
            ),
         $num(%_trackNum%,2)%_kTrackSep2%
         )
      )
   $noop(End track number.)
   
   $noop(Title.)
      $set(_title,$rreplace($rreplace($rreplace($rreplace(%_title%,
         %_kReFeat%,%_kNull%),
         %_kMultiSpace%,%_kSpace%),
         %_kRe3Dots%,%_kEllipsis%),
         %_kReAnd%,%_kAmpersand%)
         )
      $set(_title,%_title%%_trackNotes%)
      $set(title,%_title%)
      $set(_title,$rreplace($rreplace($rreplace(%_title%,
         %_kReQuestionMarks%,%_kNull%),
         %_kReQuoteMarks%,%_kSingleQuote%),
         %_kReIllegalFileChars%,%_kTrackSep3%)
         )
$noop(???)
      $set(_trackFile,
         %_artistTrack%%_albumArtistTrack%%_albumTrack%%_discNum%%_trackNum%
         %_title%
         )
   $noop(End title.)
$noop(End set up file/folder names.)

$noop(
   Finally, apply it all to the actual folders and file.
   )
%_albumArtistFolder%%_albumFolder%%_trackFile%

$noop(EDIT HISTORY
   2016-11-01 0.0.4Ī±
      1. Revamped naming convention. Now "Various Artists" is an artist and 
         the album artist goes in the track filename."[Various Artists]" will 
         be a folder at the same level as other artists. Same for "[unknown 
         artist]". "[unknown album]" will get its own folder under each 
         artist, if necessary. "[unknown artist]", "[unknown album]", and 
         "[unknown title]" will be included in track filenames, if necessary.
      2. Updated comments to reflect all that.
      3. Removed a bunch of unnecessary "_kNull"s.
      4. Bug fixes.
   2016-10-28 0.0.3Ī±
      1. Added replacing all occurrances of " and " with " & ".
      2. Added moving articles to the end of title and album.
      3. Tweaked handling for primary/secondary release types.
      4. Bug fixes.
   2016-10-27 0.0.2Ī±
      1. Added handling for all primary/secondary release types.
      2. Tweaked regex for "feat." handling.
      3. Bug fixes.
   2016-10-26 0.0.1Ī±
      1. Initial version.
   )
3 Likes

We call it ā€œtagger scriptā€ informally, and thatā€™s about as close to a real name there is. Itā€™s documented at https://picard.musicbrainz.org/docs/scripting/

1 Like

Did you guys create it? Because Iā€™ve seen at least parts of it, or of something identical, in various tagging apps going back a decade or more. Itā€™s always been only in the file naming options of those apps, never as full scripting.

If you go to https://picard.musicbrainz.org/docs/scripting/ and read it, the very first sentence under the ā€œSyntaxā€ heading (so the 2nd full sentence on the page) says:

The syntax is derived from Foobar2000ā€™s titleformat.

2 Likes

Yaeh, I missed that the first time - went straight to the functions.

A post was split to a new topic: Picard Tagger Script Language Definition for Notepad++

Hello,

I also wrote a renaming script, that I want to share with you. It moves Feat. artists from the artist tag to the title tag, but unlike the ā€˜Feat. Artists in Titlesā€™ plugin it also detects featured artists without the dots and with ā€˜ft.ā€™ instead of ā€˜feat.ā€™.

Some examples:

John Doe ft. Jane Doe - Sample track.ext or John Doe Ft. Jane Doe - Sample track.ext
would be moved to
John Doe/John Doe - Sample track feat. Jane Doe.ext

Jane Doe Feat. John Doe - Lorem ipsum.ext or Jane Doe feat John Doe - Lorem ipsum.ext
would be moved to
Jane Doe/Jane Doe - Lorem Ipsum feat. John Doe.ext

This is the script:

$set(_feat,$rsearch(%artist%,\(?<=\\sfeat\\.\).*|\(?<=\\sft\\.\).*|\(?<=\\sFt\\.\).*|\(?<=\\sFeat\\.\).*))
$set(_feat,$if(%_feat%,%_feat%,$rsearch(%artist%,\(?<=\\sfeat\\s\).*|\(?<=\\sft\\s\).*|\(?<=\\sFt\\s\).*|\(?<=\\sFeat\\s\).*)))
$set(artist,$if(%_feat%,$rreplace(%artist%, feat\\.?.*| Feat\\.?.*| Ft\\.?.*| ft\\.?.*,),%artist%))
%artist%/%artist% - %title%$if(%_feat%,$if($rsearch(%title%,\\sfeat\\.?|\\sFeat\\.?|\\sft\\.?|\\sFt\\.?),, feat.%_feat%),)

Greetings
Phil

3 Likes

I am testing your script and so far, so good. I cannot find a downside with one exception. It appears that I will need to put a bracket around my current A, B, C, etcā€¦ album order in my music library. Donā€™t know if I will have to run everything back through MBP or if just adding brackets will work. This is not a problem. I wish I had had this script 10,000 songs ago when I first started using MBP.

For my needs, this appears to be the perfect script. Very nicely done and really well documented

Thanks to ā€œYIAā€!!
Llama lover

Hey,
just quickly driving by to let you know that the link in the first post is expired since the forum is shut down now (atleast I am getting a 503 server error)

Anyway, here is a link that works as long as the wayback machine by archive.org is working:

https://web.archive.org/web/20150801233129/http://forums.musicbrainz.org/viewtopic.php?id=514

A Snapshot of the 5 pages of that old forum post.
My personal favorite is still this one:

$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%

To get:

root/B/The Beatles/1965 -- Help!/07. The Beatles - Ticket to Ride.mp3
root/V/Various Artists/2005 -- Coup d'Ɖtat ...

Itā€™s pretty simple and does the job for me.

1 Like

I am horrible with scripts can someone tell me a simple script to make it Artists First Name Letter/Artists/Album Name/

Then the file nameing convention to be Artist - Title

So for example it would save it to (music folder of my choosing) M/Michael Jackson/Dangerous/ Michael Jackson - Dangerous.mp3

?

Try

$firstalphachar($delprefix(%artist%,prefixes=A,An,The),#)/%artist%/%album%/%artist% - %title%

and see if that does what you want. Note that this files by the track artist and not the album artist because thatā€™s the way you specified it. Personally, I would suggest

$firstalphachar($delprefix(%albumartist%,prefixes=A,An,The),#)/%albumartist%/%album%/%artist% - %title%

instead because this will sort the albums by album artist and then sort the tracks by track artist.

1 Like

TheBradleys - your script is almost exactly what i am looking for, except that i would lose the A,B,Cā€¦ level and have Album artist as the listing in the root folder.
Now sorry to wimp out but my head hurts looking at how to do that from yours. Could you post your script with that change?

1 Like

I had thought I already posted my script, but I guess it slipped my mind.
This script gives a layer of folders with the initial letter of the album artist sort name, then the sort name itself, next the album name, with release comment, and single or EP if appropriate. The songs are in the form: Track number - artist - title. Multiple disc releases are all in the same folder with the disc number tacked on to the front of the track number.
Back at the root level, there are separate folders for soundtracks and various artist compilations. Under those, thereā€™s another layer of initial letters, this time of the swapprefixā€™ed album names, then those names, with the file names under those in the same format as before.

Examples:
Tagged Music\~D~\Dylan, Bob\Blood on the Tracks\01 - Bob Dylan - Tangled Up in Blue.mp3
Tagged Music\~C~\Crosby, Bing\Bing Sings 96 of His Greatest Hits\711 - Bing Crosby with The Andrews Sisters - Victā€™ry Polka.mp3
Tagged Music\Soundtrack\~W~\Wizard of Oz, The\02 - Harold Arlen - Over the Rainbow.mp3
Tagged Music\Various Artists\~1~\1959- Jazzā€™s Greatest Year\02 - Miles Davis & Gil Evans - The Pan Piper.mp3
Tagged Music\~M~\Mann, Manfred, Earth Band\Blinded by the Light _ Spirit in the Night (Single)\01 - Manfred Mannā€™s Earth Band - Blinded By The Light.mp3
Tagged Music\~D~\Dire Straits\ExtendedancEPlay (EP)\01 - Dire Straits - Twisting by the Pool.mp3
Tagged Music\~R~\Rush\R40 Live (Only @ Best Buy version with starman flashlight)\210 - Rush - 2112.mp3

    $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(%_releasecomment%, \(%_releasecomment%\),$noop())
    	$if($in(%releasetype%,single), \(Single\),$noop())
    	$if($in(%releasetype%,ep), \(EP\),$noop())/
    	$if($gt(%totaldiscs%,1),%discnumber%,$noop())
    	$num(%tracknumber%,2) - %artist% - %title%,
    		$if($eq(%albumartist%,Various Artists),
    		$noop(Various artist albums)
    		Various Artists/~
    		$left($swapprefix(%album%,A,An,The),1)~/$swapprefix(%album%,A,An,The)
    		$if(%_releasecomment%, \(%_releasecomment%\),$noop())
    		$if($in(%releasetype%,single), \(Single\),$noop())
    		$if($in(%releasetype%,ep), \(EP\),$noop())/
    		$if($gt(%totaldiscs%,1),%discnumber%,$noop())
    		$num(%tracknumber%,2) - %artist% - %title%,
    		$noop(Normal albums)
    		~$left($if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%),1)~/
    		$if2(%albumartistsort%,%artistsort%,%albumartist%,%artist%)/%album%
    		$if(%_releasecomment%, \(%_releasecomment%\),$noop())
    		$if($in(%releasetype%,single), \(Single\),$noop())
    		$if($in(%releasetype%,ep), \(EP\),$noop())/
    		$if($gt(%totaldiscs%,1),%discnumber%,$noop())
    		$num(%tracknumber%,2) - %artist% - %title%)
    )
    ,*,[x])
    ,?,)
    ,:,-)
    ,",')
    ,<,{)
    ,>,})
2 Likes

This is mine so far: You can customize it to your liking, which is located at the very bottom.
The default output looks like this:

-=A =-/Amy Winehouse/Back to Black [2007]/Disc 1/Amy Winehouse - Back to Black - 01 - Rehab.mp3

Disc folders are only created if it has more than 2 discs. If you still do not want to display the disc folders, then I recommend changing %Track1% to %Track2%. This will add the disc number 1- to the track number. Just like how it is displayed by default in MusicBee.

$noop( *** DO NOT EDIT THE AREA BELOW | EDITABLE AREA WILL BE AT THE VERY BOTTOM *** )
			$set(MainFolder1,-= $upper($left(%albumartist%,1)) =-/)
			$set(MainFolder2,-= $upper($left(%albumartistsort%,1)) =-/)
			$set(MainFolder3,)
			$set(Artist1,$replace($rreplace(%albumartist%,[_:], -),?,)/)
			$set(Artist2,$replace($rreplace(%albumartistsort%,[_:],-),?,)/)
			$set(Album1,$replace($rreplace(%album%,[_:], -),?,)$if(%date%,$if(%album%, )[$left(%date%,4)])/)
			$set(Album2,$replace($rreplace(%album%,[_:], -),?,)/)
			$set(MultiDisc1,$if($gt(%totaldiscs%,1),Disc $num(%discnumber%,1)/)
			$set(MultiDisc2,)
			$set(PreTitle1,%albumartist% - %album% -)
			$set(PreTitle2,)
			$set(Track1, $num(%tracknumber%,2) - )
			$set(Track2, $num(%discnumber%,1)-$num(%tracknumber%,2) - ))
			$set(Title,%title%)
$noop( *** DO NOT EDIT THE AREA ABOVE| EDITABLE AREA IS JUST BELOW *** )




$noop( *** The Following will use the example of artist: Amy Winehouse and album: Back to Black *** )
$noop( *** Default output: -=A =-/Amy Winehouse/Back to Black [2007]/Disc 1/Amy Winehouse - Back to Black - 01 - Rehab *** )
$noop( *** Change the NUMERICAL value ONLY! Example: %MainFolder1% would be changed to %MainFolder2% *** )
$noop( *** Only change the numerical value to either 1 or 2, anything else will mess things up. *** )
%MainFolder1%	$noop( OPTION 1 -= A=- | OPTION 2 -= W =- | OPTION 3 = No single character folder will be created. )
%Artist1%			$noop( OPTION 1 = Amy WineHouse| OPTION 2 = Winehouse, Amy )
%Album1%			$noop( OPTION 1 = Back to Black [2007] | OPTION 2 = Back to Black )
%MultiDisc1%		$noop( OPTION 1 = If album has more than 1 Disc, then add Disc folders | OPTION 2 = Do not sort by Disc, put all files into a single folder. )
%PreTitle1%		$noop( OPTION 1 = Show Artist and Album in the track title | OPTION 2 = Do not display Artist or Album)
%Track1%			$noop( OPTION 1 = Track Number: 01 | OPTION 2: Track Number: 1-01-> This is best if MultiDisc is set to 2, because you will have 2 track numbers as 01 - *track names*, etc. )
%Title%				$noop( NO OPTION - Just display the name of the track. )
1 Like