[SOLVED] Artist case mismatch in filenaming script

Tags: #<Tag:0x00007f58fa6e32f0>

Hi y’all, I’ve been an avid user of Picard for many years now and made tons of scripts, usually because I kept forgetting to save them whenever I periodically wiped my computer to get rid of all the cruft I collect…

I’ve rewritten rdswifts filenaming script to accomodate my personal preferences but for some reason which eludes me, all the artistnames in the filenames have been transformed to lowercase. I’ve been debugging for several hours now and I could really use a fresh pair of eyes. Can somebody please tell me where I messed up?

Many thanks in advance!!!

$noop( ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
  ❄❄❄❄  About  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄❄  Pegasus' Picard File Naming Script v0.1.0-dev                 2021-03-04  ❄❄
❄   CopyLeft 🄯 2021 Mattijs Snepvangers [pegasusict]                           ❄
❄   based on rdswift's Filenaming script                                       ❄
❄❄  License: GPLv3.0                                                          ❄❄
  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄❄      This script relies on inputs provided by the following plugins:       ❄❄
❄❄    ⇒ Additional Artists Variables [AAV]                                    ❄❄
  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)

$noop(❄ User Settings  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_PaddedDiscNumMinLength,1)
$set(_PaddedTrackNumMinLength,2)
$set(_aTitleMaxLength,65)
$set(_tTitleMaxLength,65)
$set(_tFilenameMaxLength,120)
$set(_aTitleReleaseYear,)$noop(binary switch)
$set(_aTitleDisambig,1)$noop(binary switch)
$set(_aTitleLabel,)$noop(binary switch)
$set(_aTitleCatalog,)$noop(binary switch)
$noop(collate compilation tracks under "trackartist/[Compilations]/" - binary switch)
$set(_aCollateCompilations,1)
$noop(collate Singles' tracks under "trackartist/[Singles]/" - binary switch)
$set(_aCollateSingles,1)
$set(_aTitleCatalog,)$noop(binary switch)
$setmulti(_Prefixes,THE; The; the; A; a; AN; An; an; DE; De; de; EEN; Een; een; HET; Het; het; LE; Le; le)
$noop(❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)

$noop(❄ Constants  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_cScriptName,Pegasus' Picard File Naming Script)
$set(_cScriptVersion,0.1.0-alpha)
$set(_cScriptBuild,2021-03-04)
$set(_cScriptAuthor,Mattijs Snepvangers [pegasusict])
$set(_cScriptUrl,https://github.com/pegasusict/MuzicbrainzPicard-stuff)
$set(_cScriptLicense,GPLv3.0)
$set(_cSignature,Processed by MusicBrainz Picard at $datetime() using
 %_cScriptName% v%_cScriptVersion% build%_cScriptBuild%. %_cScriptUrl%)

$set(_cUnknownArtistID,125ec42a-7229-4250-afc5-e057484327fe)
$set(_cVariousArtistID,89ad4ac3-39f7-470e-963a-56509c546377)
$set(_cUnknownArtist,[Unknown Artist])$noop(❄❄❄ TODO: option to isolate from index folders ❄❄❄)
$set(_cVariousArtist,[Various Artists])
$set(_cUnknownAlbum,[Unknown Album])
$set(_cNoTitle,[Unknown Title])
$set(_cClassical,[Classical])
$set(_cSoundtrack,[Soundtracks])
$set(_cCompilation,[Compilations])
$set(_cSingles,[Singles])
$set(_cOther,[Other])
$noop(❄  RegEx Constants  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_reCaseInsensitive,\(?i\))
$noop(❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)


$noop(❄ Setting sensible default values if AAV plugin or metadata is missing. ❄❄)
$set(_nFAA,$if2(%_artists_album_all_std%,%albumartist%,%_cUnknownArtist%))
$set(_nPAA,$if2(%_artists_album_primary_std%,%albumartist%,%_cUnknownArtist%))
$set(_nFAAS,$if2(%_artists_album_all_sort%,%albumartistsort%,%_cUnknownArtist%))
$set(_nPAAS,$if2(%_artists_album_primary_sort%,%albumartistsort%,%_cUnknownArtist%))
$set(_nFAAPS,$if2(%_artists_album_all_sort_primary%,%albumartistsort%,%_cUnknownArtist%))
$set(_nPTA,$if2(%_artists_track_primary_cred%,%artist%,%_cUnknownArtist%))
$set(_nATA,%_artists_track_additional_cred%)
$set(_nFTA,$if2(%_artists_track_all_cred%,%artist%,%_cUnknownArtist%))
$set(_nAN,$if2(%album%,%_cUnknownAlbum%))
$set(_nANT,$if2(%album%,%_cUnknownAlbum%))
$set(_nTNT,$if2(%title%,%_cNoTitle%))


$noop(❄ Initialize Working Variables  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_nMedia,%media%)
$set(_nTotalDiscs,$if2(%totaldiscs%,1))
$set(_nDiscNum,$if2(%discnumber%,1))
$set(_nTotalTracks,$if2(%totaltracks%,1))
$set(_nTrackNum,$if2(%tracknumber%,1))
$set(_nAlbumArtistID,$if2(%musicbrainz_albumartistid%,%_kUnKnownArtistID%))
$set(_nIsCompilation,$if($or($gt(%_artists_album_all_count%,1),%compilation%),1,))
$set(_nCCIC,$if($and(%_aCollateCompilations%,%_nIsCompilation%),1,))
$set(_nIsSingle,$if($or($lte(%_nTotaltracks%,2),$eq(%_primaryreleasetype%,single)),1,))
$set(_nCSIS,$if($and(%_aCollateSingles%,%_nIsSingle%),1,))
$if(%_nCCIC%,$set(_nANT,%_cCompilation%),)
$if(%_nCSIS%,$set(_nANT,%_cSingle%),)
$set(_nInitial,$upper($firstalphachar(%_nPAAS%,0-9))/)
$set(_nYear,[$if($or(%_nCCIC%,%_nCSIS%),0000,$left($if2(%originaldate%,%originalyear%,%date%,0000),4))])
$set(_nBR,[$rreplace(%_bitrate%,\\.\\d*\$,)])
$set(_nLen,[%_length%])

$noop( ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄❄  If standardized primary album artist is different from credited primary    ❄❄
❄   any track artist [other than prefix] show in track file name. Otherwise,     ❄
❄❄  show additional credited track artists in track file name.                 ❄❄
  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_tAlbumArtist,$lower($swapprefix(%_nPAA%, %_Prefixes%)))
$set(_tTrackArtist,$lower($swapprefix(%_nPTA%, %_Prefixes%)))
$if($eq(%_tAlbumArtist%,%_tTrackArtist%),
$set(_nFeat,$if(%_nATA%, [feat. %_nATA%],)),$set(_nFeat, [%_nFTA%]))

$noop(❄❄  Calculate and apply padding for disc and track numbers. ❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$if($not($or(%_nCCIC%,%_nCSIS%)),
$if($gt(%_nTotalDiscs%,1),
$set(_TotalDiscNumberLength,$len($if2(%totaldiscs%,1)))
$set(_DiscPadLength,$if($gt(%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%),
%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%))
$set(_PaddedDiscNum,$num($if2(%discnumber%,1),%_DiscPadLength%)-),$noop()
)
$set(_TotalTrackNumberLength,$len($if2(%totaltracks%,1)))
$set(_TrackPadLength,$if($gt(%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%),
%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%))
$set(_nTNum,%_PaddedDiscNum%$num($if2(%tracknumber%,1),%_TrackPadLength%))
,)
$noop( ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄❄  Add disambiguation, release year, label and catalog number to the         ❄❄
❄❄  album title information if available and enabled in "User Settings".      ❄❄
  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_nDisambig,$if($and(%_releasecomment%,%_aTitleDisambig%), \(%_releasecomment%\),))
$set(_nTitleExtra,)
$if(%_aTitleLabel%,$if(%label%,$setmulti(_temp,%label%)$set(_nTitleExtra,$getmulti(%_temp%,0))))
$if(%_aTitleCatalog%,$if(%catalognumber%,$setmulti(_temp,%catalognumber%)$set(_nTitleExtra,$trim(%_nTitleExtra% $getmulti(%_temp%,0)))))
$if(%_aTitleReleaseYear%,$if(%date%,$set(_temp,[$left(%date%,4)])
$if($ne([%_temp%],%_nYear%),$if(%_nTitleExtra%,$set(_nTitleExtra,%_nTitleExtra%\,))$set(_nTitleExtra,$trim(%_nTitleExtra% %_temp%)))))
$if(%_nTitleExtra%,$set(_nTitleExtra, [%_nTitleExtra%]))
$set(_nANT,%_nANT%%_nDisambig%%_nTitleExtra%)

$noop(❄  Remove any illegal characters  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_nANT,$replace_forbidden(%_nANT%))
$set(_nTNT,$replace_forbidden(%_nTNT%))

$noop( ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄❄  Trim the album and track names used to create directories and             ❄❄
❄   tracks if they are longer than the maximum lengths set in the              ❄
❄❄  "User Settings" section.                                                  ❄❄
  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$if($gt($len(%_nANT%),%_aTitleMaxLength%),$set(_nANT,$left(%_nANT%,$sub(%_aTitleMaxLength%,1))…))
$if($gt($len(%_nTNT%),%_tTitleMaxLength%),$set(_nTNT,$left(%_nTNT%,$sub(%_tTitleMaxLength%,1))…))

$noop(❄  Set File Path  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$if($eq_any(%musicbrainz_albumartistid%,%_cVariousArtistID%,%_cUnknownArtistID%),
$set(_nInitial,$upper($firstalphachar(%_nPTA%,0-9))/)$set(_nArtist,%_nPTA%),
$set(_nArtist,%_nPAAS%)
)
$set(_nFilePath,%_nInitial%/%_nArtist%/%_nYear% %_nANT%/)

$noop(❄  Set FileName  ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(_nFileName,$if($not($or(%_nCCIC%,%_nCSIS%)),%_nTNum%. ,)%_tTrackArtist% - %_nTNT%)
$set(_tFilenameMaxLength,$sub(%_tFilenameMaxLength%,17))
$if($gt($len(%_nFileName%),%_tFilenameMaxLength%),$set(_nFileName,$left(%_nFileName%,%_tFilenameMaxLength%)…))
$set(_nFileName,%_nFileName% %_nLen% %_nBR%)

$noop(❄  Result ❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄)
$set(ProcessedBy,%_cSignature%)
$set(OutputPath,$rreplace(%_nFilePath%,[?*:\\_]+,_))
$set(OutputFileName,$rreplace(%_nFileName%,[?*:\\_]+,_))

%OutputPath%/%OutputFileName%

Not sure, but there are those two lines setting variables for album and track artist:

$set(_tAlbumArtist,$lower($swapprefix(%_nPAA%, %_Prefixes%)))
$set(_tTrackArtist,$lower($swapprefix(%_nPTA%, %_Prefixes%)))
2 Likes

No, they’re only used in the line directly beneath them.

I stand corrected, That’s the culprit! Many Thanks!

My fix:

$set(_tTrackArtist,$swapprefix(%_nPTA%, %_Prefixes%))
$if($eq(%_tAlbumArtist%,$lower(%_tTrackArtist%)),

and updated :wink:

2 Likes