File Renaming with Musicbrainz Picard

05.12.2020

Last modified: 08.12.2020
estimated reading time 3 min

Musicbrainz Picard is a comprehensive tool to organize your music library. It can rename existing files based on scripting variables.

See below example to rename files

$set(artist,$rreplace(%artist%,["*:<>?|],))
$set(album,$rreplace(%album%,["*:<>?|],))
$set(title,$rreplace(%title%,["*:<>?|],))
$if(
$eq(Non-Album Tracks,%album%),
%album%/%artist%/%artist% - %title%,
$if(
$and(
$eq(%compilation%,1),
$eq(%albumartist%,Various Artists)
),
$unset(albumartist)
$unset(albumartistsort)
)
$if(
$eq(%compilation%,1),
Compilations/%album% \($left(%date%,4)\)/
$if(
$gt(%totaldiscs%,1),
$num(%discnumber%,2)-,
)
$if(
$ne(%tracknumber%,),
$num(%tracknumber%,2). %artist% - %title%,
%artist% - %title%
),
$if2(%albumartist%,%artist%)/
$if(
$ne(%date%,),
%album% \($left(%date%,4)\)/,
%album%/
)
$if(
$gt(%totaldiscs%,1),
$num(%discnumber%,2)-,
)
$if(
$ne(%tracknumber%,),
$num(%tracknumber%,2). %title%,
%title%
)
)
)

If you are using Notepad ++ you can enable syntax highlighting by importing the following picard-syntax.xml as User-Defined Language in Notepad++

<NotepadPlus>
    <UserLang name="Picard scripting - light" ext="txtp" udlVersion="2.1">
        <Settings>
            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="2" />
            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
        </Settings>
        <KeywordLists>
            <Keywords name="Comments">00# 01 02((EOL)) 03$noop 04)</Keywords>
            <Keywords name="Numbers, prefix1"></Keywords>
            <Keywords name="Numbers, prefix2"></Keywords>
            <Keywords name="Numbers, extras1"></Keywords>
            <Keywords name="Numbers, extras2"></Keywords>
            <Keywords name="Numbers, suffix1"></Keywords>
            <Keywords name="Numbers, suffix2"></Keywords>
            <Keywords name="Numbers, range"></Keywords>
            <Keywords name="Operators1">$while $upper $unset $truncate $trim $title $swapprefix $substr $sub $strip $startswith $slice $setmulti $set $rsearch $rreplace $right $reverse $replace $performer $pad $or $num $not $ne_any $ne_all $ne $mul $mod $matchedtracks $map $lte $lt $lower $lenmulti $len $left $join $is_video $is_complete $is_audio $inmulti $initials $in $if2 $if $gte $gt $getmulti $get $foreach $firstwords $firstalphachar $find $eq_any $eq_all $eq $endswith $div $delprefix $delete $datetime $copymerge $copy $and $add , / " % [ ^ \ ] * ;</Keywords>
            <Keywords name="Operators2"></Keywords>
            <Keywords name="Folders in code1, open"></Keywords>
            <Keywords name="Folders in code1, middle"></Keywords>
            <Keywords name="Folders in code1, close"></Keywords>
            <Keywords name="Folders in code2, open"></Keywords>
            <Keywords name="Folders in code2, middle"></Keywords>
            <Keywords name="Folders in code2, close"></Keywords>
            <Keywords name="Folders in comment, open"></Keywords>
            <Keywords name="Folders in comment, middle"></Keywords>
            <Keywords name="Folders in comment, close"></Keywords>
            <Keywords name="Keywords1">$Upper $Unset $Truncate $Trim $Title $Swapprefix $Sub $Strip $Startswith $Setmulti $Set $Rsearch $Rreplace $Right $Replace $Performer $Pad $Or $Num $Not $Noop $Ne_any $Ne_all $Ne $Mul $Mod $Matchedtracks $Lte $Lt $Lower $Len $Left $Is_video $Is_complete $Is_audio $Inmulti $Initials $In $If2 $If $Gte $Gt $Get $Firstwords $Firstalphachar $Eq_any $Eq_all $Eq $Endswith $Div $Delprefix $Delete $Copymerge $Copy $And $Add</Keywords>
            <Keywords name="Keywords2">"Album artist" "Album Artist" "album artist"</Keywords>
            <Keywords name="Keywords3">writer work website tracknumber totaltracks totaldiscs titlesort title subtitle showsort show script remixer releasetype releasestatus releasecountry producer podcasturl podcast performer: originalyear originalfilename originaldate originalartist originalalbum musicip_puid musicip_fingerprint musicbrainz_workid musicbrainz_trmid musicbrainz_trackid musicbrainz_releasetrackid musicbrainz_releasegroupid musicbrainz_recordingid musicbrainz_originalartistid musicbrainz_originalalbumid musicbrainz_discid musicbrainz_artistid musicbrainz_albumid musicbrainz_albumartistid mood mixer media lyrics lyricist license language label key isrc grouping genre gapless engineer encodersettings encodedby djmixer discsubtitle discnumber discid date copyright conductor composersort composer compilation comment catalognumber bpm barcode asin artistsort artists artist arranger albumsort albumartistsort albumartist album acoustid_id acoustid_fingerprint _totalalbumtracks _secondaryreleasetype _sample_rate _releaselanguage _releasegroupcomment _releasegroup _releasecomment _recordingtitle _recordingcomment _rating _primaryreleasetype _multiartist _length _format _filename _extension _dirname _channels _bits_per_sample _bitrate _artists_sort _albumartists_sort _albumartists _absolutetracknumber</Keywords>
            <Keywords name="Keywords4">_variables _cwp_writers_sort _cwp_writers _cwp_workid_top _cwp_workid_ _cwp_work_top _cwp_work_part_levels _cwp_work_ _cwp_work _cwp_untagged_genres _cwp_unrostered_composers _cwp_translators_sort _cwp_translators _cwp_title_work_levels _cwp_title_work_ _cwp_title_work _cwp_title_part_levels _cwp_title_part_ _cwp_title_groupheading _cwp_title _cwp_single_work_album _cwp_revisors_sort _cwp_revisors _cwp_reconstructors_sort _cwp_reconstructors _cwp_published_dates _cwp_premiered_dates _cwp_part_levels _cwp_part_ _cwp_part _cwp_orchestrators_sort _cwp_orchestrators _cwp_movt_tot _cwp_movt_num _cwp_lyricists_sort _cwp_lyricists _cwp_librettists_sort _cwp_librettists _cwp_keys _cwp_inter_work _cwp_groupheading _cwp_extended_work _cwp_extended_part _cwp_extended_inter_work _cwp_extended_groupheading _cwp_composers_sort _cwp_composers _cwp_composer_lastnames _cwp_composed_dates _cwp_candidate_genres _cwp_arrangers_sort _cwp_arrangers _cwp_arranger_names _cea_work_type_if_classical _cea_work_type _cea_vocalists _cea_vocalist_names _cea_support_performers_sort _cea_support_performers _cea_soloists_sort _cea_soloists _cea_soloist_names _cea_recording_artistsort _cea_recording_artists_sort _cea_recording_artists _cea_recording_artist _cea_performers _cea_other_soloists _cea_orchestrators _cea_leaders _cea_instuments_credited _cea_instruments_all _cea_instruments _cea_instrumentalists _cea_instrumentalist_names _cea_ensembles_sort _cea_ensembles _cea_ensemble_names _cea_conductors _cea_composers _cea_composer_lastnames _cea_chorusmasters _cea_arrangers _cea_album_track_composer_lastnames _cea_album_soloists_sort _cea_album_soloists _cea_album_ensembles_sort _cea_album_ensembles _cea_album_conductors_sort _cea_album_conductors _cea_album_composers_sort _cea_album_composers _cea_album_composer_lastnames _cea_MB_artists _artists_track_primary_std _artists_track_primary_sort _artists_track_primary_id _artists_track_primary_cred _artists_track_all_std_multi _artists_track_all_std _artists_track_all_sort_primary _artists_track_all_sort _artists_track_all_cred_multi _artists_track_all_cred _artists_track_all_count _artists_track_additional_std_multi _artists_track_additional_std _artists_track_additional_sort _artists_track_additional_id _artists_track_additional_cred_multi _artists_track_additional_cred _artists_album_primary_std _artists_album_primary_sort _artists_album_primary_id _artists_album_primary_cred _artists_album_all_std_multi _artists_album_all_std _artists_album_all_sort_primary _artists_album_all_sort _artists_album_all_cred_multi _artists_album_all_cred _artists_album_all_count _artists_album_additional_std_multi _artists_album_additional_std _artists_album_additional_sort _artists_album_additional_id _artists_album_additional_cred_multi _artists_album_additional_cred _aaeStdPrimaryAlbumArtist _aaeStdAlbumArtists _aaeSortPrimaryAlbumArtist _aaeSortAlbumArtists _aaeCredPrimaryAlbumArtist _aaeCredAlbumArtists _aaeAlbumArtistCount _TArtistCount _PriTArtistStd _PriTArtistSort _PriTArtistID _PriTArtistCred _PriAArtistStd _PriAArtistSort _PriAArtistID _PriAArtistCred _FullTArtistStd _FullTArtistSort _FullTArtistPriSort _FullTArtistCred _FullAArtistStd _FullAArtistSort _FullAArtistPriSort _FullAArtistCred _AdditionalTArtistStd _AdditionalTArtistID _AdditionalTArtistCred _AdditionalAArtistStd _AdditionalAArtistID _AdditionalAArtistCred _AArtistCount</Keywords>
            <Keywords name="Keywords5">user_area:_feel_free_to_use_as_required</Keywords>
            <Keywords name="Keywords6">user_area:_feel_free_to_use_as_required</Keywords>
            <Keywords name="Keywords7">user_area:_feel_free_to_use_as_required</Keywords>
            <Keywords name="Keywords8">user_area:_feel_free_to_use_as_required</Keywords>
            <Keywords name="Delimiters">00( 01 02) 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
        </KeywordLists>
        <Styles>
            <WordsStyle name="DEFAULT" fgColor="5E6060" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="COMMENTS" fgColor="82828A" bgColor="F2F2F2" fontName="Verdana" fontStyle="2" fontSize="8" nesting="0" />
            <WordsStyle name="LINE COMMENTS" fgColor="82828A" bgColor="F2F2F2" fontName="Verdana" fontStyle="2" fontSize="8" nesting="0" />
            <WordsStyle name="NUMBERS" fgColor="5E6060" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS1" fgColor="D20000" bgColor="F2F2F2" fontName="Source Code Pro Semibold" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS2" fgColor="7A8B83" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS3" fgColor="245CC5" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS4" fgColor="2A751B" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS5" fgColor="A44ED9" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS6" fgColor="A44ED9" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS7" fgColor="A44ED9" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="KEYWORDS8" fgColor="A44ED9" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="OPERATORS" fgColor="AD4B00" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="FOLDER IN CODE1" fgColor="FF0000" bgColor="004080" fontName="슰᢬Ɖ" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN CODE2" fgColor="FFFF00" bgColor="804040" fontName="瓠ᢢƉ" fontStyle="0" nesting="0" />
            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="44085" fontStyle="0" nesting="0" />
            <WordsStyle name="DELIMITERS1" fgColor="5E6060" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="17039105" />
            <WordsStyle name="DELIMITERS2" fgColor="8080FF" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="16777216" />
            <WordsStyle name="DELIMITERS3" fgColor="8080FF" bgColor="323232" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="DELIMITERS4" fgColor="8C8C8C" bgColor="323232" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="DELIMITERS5" fgColor="A752B4" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="DELIMITERS6" fgColor="5382BA" bgColor="F2F2F2" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="DELIMITERS7" fgColor="5382BA" bgColor="0A0A0A" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro Medium" fontStyle="0" fontSize="10" nesting="0" />
        </Styles>
    </UserLang>
</NotepadPlus>

Now if you choose Picard Tagging as Language you will get the scripting for the file-renaming and tagging in Picard nicely syntax-highlighted.

Tags:
Was this article helpful?
Dislike 0
Views: 79

Search