Repository for neat file name string patterns and tagger script snippets

You probably need \\ (two slashes…) (and laughs when Discord makes me type four slashes to make those two appear…)

I’ve written a plugin to do this for my track names. I strip out many Unicode characters so things are consistent for searches in my Media Centre.

1 Like

Hm the issue was “/” not the backslash, no need to escape in theory.
I found out the solution, i had to replace “_” instead of “/”, as the slashes were already made into underscores, maybe by previous renaming or just out of the box by Picard, don’t know but it’s solved :slight_smile:

Because the slash is used to create a directory in the file naming scripts, I believe that it is already processed into an underscore before it gets to the naming script.

2 Likes

Yeah that’s it. I’m posting my mods to your script if someone wanna try.


$noop(
########################################################################
#                                                                      #
#  Picard File Naming Script                               2022-10-14  #
#  Bob Swift [rdswift]                                                 #
#                                                                      #
#  License: GPLv3.0                                                    #
#                                                                      #
########################################################################
#                                                                      #
#  This script relies on the following inputs provided by the          #
#  "Additional Artists Variables" plugin:                              #
#                                                                      #
#  Album Variables                                                     #
#                                                                      #
#      _artists_album_primary_std - The primary / first album artist   #
#               listed [standardized]                                  #
#      _artists_album_primary_sort - The primary / first album         #
#               artist listed [sort name]                              #
#      _artists_album_all_std - All album artists listed               #
#               [standardized], separated with strings provided from   #
#               the release entry                                      #
#      _artists_album_all_sort - All album artists listed              #
#               [sort names], separated with strings provided from     #
#               the release entry                                      #
#      _artists_album_all_sort_primary - The primary / first album     #
#               artist listed [sort name] followed by all additional   #
#               album artists [standardized], separated with strings   #
#               provided from the release entry                        #
#                                                                      #
#  Track Variables                                                     #
#                                                                      #
#      _artists_track_primary_cred - The primary / first track artist  #
#               listed [as credited]                                   #
#      _artists_track_additional_cred - All track artists listed [as   #
#               credited] except for the primary / first artist,       #
#               separated with strings provided from the track entry   #
#      _artists_track_all_cred - All track artists listed              #
#               [as credited], separated with strings provided from    #
#               the track entry                                        #
#                                                                      #
########################################################################
)


$noop(
########################################################################
#                                                                      #
#  User Settings:                                                      #
#                                                                      #
#  _PaddedDiscNumMinLength - Minimum length to pad disc numbers        #
#  _PaddedTrackNumMinLength - Minimum length to pad track numbers      #
#  _aTitleMaxLength - Maximum length of album title in file name       #
#  _tTitleMaxLength - Maximum length of track title in file name       #
#  _tFilenameMaxLength - Overall maximum length of track file name     #
#                                                                      #
#                                                                      #
#  Processing Flags [set to '1' to include or '' to omit]:             #
#                                                                      #
#  _aTitleReleaseYear - Add the release year to the title              #
#  _aTitleDisambig - Add the disambiguation to the title               #
#  _aTitleLabel - Add the label information to the title               #
#  _aTitleCatalog - Add the catalogue number to the title              #
#                                                                      #
########################################################################
)
$set(_PaddedDiscNumMinLength,1)
$set(_PaddedTrackNumMinLength,2)
$set(_aTitleMaxLength,200)
$set(_tTitleMaxLength,200)
$set(_tFilenameMaxLength,259)

$set(_aTitleReleaseYear,)
$set(_aTitleDisambig,)
$set(_aTitleLabel,)
$set(_aTitleCatalog,)


$noop(
########################################################################
#                                                                      #
#  Constants                                                           #
#                                                                      #
#  _cUnknownArtistID - MBID of "Unknown Artist"                        #
#  _cVariousArtistID - MBID of "Various Artists"                       #
#  _cUnknownArtist - Text to use for "Unknown Artist"                  #
#  _cVariousArtist - Text to use for "Various Artists"                 #
#  _cUnknownAlbum - Text to use for unknown album title                #
#  _cNoTitle - Text to use for unknown track title                     #
#  _cClassical - Text to use for path to classical albums              #
#  _cSoundtrack - Text to use for path to soundtrack albums            #
#  _cSingles - Text to use as album title for singles by an artist     #
#  _cOther - Text to use for path to other albums                      #
#                                                                      #
########################################################################
)
$set(_cUnknownArtistID,125ec42a-7229-4250-afc5-e057484327fe)
$set(_cVariousArtistID,89ad4ac3-39f7-470e-963a-56509c546377)
$set(_cUnknownArtist,[Unknown Artist])
$set(_cVariousArtist,[Various Artists])
$set(_cUnknownAlbum,[Unknown Album])
$set(_cNoTitle,[Unknown Title])
$set(_cClassical,[Classical])
$set(_cSoundtrack,[Soundtracks])
$set(_cOther,[Other])


$noop(
########################################################################
#                                                                      #
#  RegEx Constants                                                     #
#                                                                      #
########################################################################
)
$set(_reCaseInsensitive,\(?i\))


$noop(
########################################################################
#                                                                      #
#  Variables used for processing, set to defaults if "Additional       #
#  Artists Variables" plugin not loaded or metadata is missing:        #
#                                                                      #
#  _nFAA - All album artists [standard]                                #
#  _nPAA - Primary album artist [standard]                             #
#  _nFAAS - All album artists [sort]                                   #
#  _nPAAS - Primary album artist [sort]                                #
#  _nFAAPS - All album artists [primary artist sort]                   #
#  _nPTA - Primary track artist [credited]                             #
#  _nATA - Additional track artists [credited]                         #
#  _nFTA - All track artists [credited]                                #
#  _nAN - Album title                                                  #
#  _nANT - Album title [with additional information added later]       #
#  _nTN - Track title                                                  #
#  _nTNT - Track title [with additional information added later]       #
#                                                                      #
########################################################################
)
$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(_nTN,$if2(%title%,%_cNoTitle%))
$set(_nTNT,$if2(%title%,%_cNoTitle%))


$noop(
########################################################################
#                                                                      #
#  Replace special characters in the album and track artists used in   #
#  the output file path and name.                                      #
#                                                                      #
#  Note that some of these replacements may revert back to an          #
#  underscore because of processing for Windows compatability.         #
#                                                                      #
########################################################################
)
$foreach(_nFAA; _nFAAS; _nPAA; _nPAAS; _nFAAPS; _nPTA; _nATA; _nFTA,
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[_],•))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[*],-))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[/],\u2571))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),:, \u2236))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[?],!))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[`´‘’ʻ""“”],'))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]3,…))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]2_,…)))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[._]*\$,))

$noop(
########################################################################
#                                                                      #
#  Replace special characters in the album and track title used in     #
#  the output file path and name.                                      #
#                                                                      #
#  Note that some of these replacements may revert back to an          #
#  underscore because of processing for Windows compatability.         #
#                                                                      #
########################################################################
)
$foreach(_nAN; _nANT; _nTN; _nTNT,
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[_],•))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[*],-))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[:], \u2236))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[?],!))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[`´‘’ʻ""“”],'))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]3,…))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]2_,…)))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[._]*/\$],))

$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(_nInitial,~ $upper($firstalphachar(%_nFAAPS%,#)) ~/)

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

$noop(
------------------------------------------------------------------------
-  Calculate the maximum lengths for disc and track numbers and set    -
-  the desired padding lengths.                                        -
------------------------------------------------------------------------
)
$set(_TotalDiscNumberLength,$len($if2(%totaldiscs%,1)))
$set(_TotalTrackNumberLength,$len($if2(%totaltracks%,1)))
$set(_DiscPadLength,$if($gt(%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%),%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%))
$set(_TrackPadLength,$if($gt(%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%),%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%))

$noop(
------------------------------------------------------------------------
-  Automatically pad disc and track numbers to the length of the       -
-  total number of discs and tracks.                                   -
------------------------------------------------------------------------
)
$set(_PaddedDiscNum,$num($if2(%discnumber%,1),%_DiscPadLength%))
$set(_PaddedTrackNum,$num($if2(%tracknumber%,1),%_TrackPadLength%))

$noop(
------------------------------------------------------------------------
-  Set the year for the release                                        -
------------------------------------------------------------------------
)
$set(_nYear,
	$if($gt($left($if2(%originaldate%,%originalyear%,%date%),4),1400),
	$left($if2(%originaldate%,%originalyear%,%date%),4).))

$noop(
------------------------------------------------------------------------
-  Add the disc number to the track number if there is more than one   -
-  disc in the album.                                                  -
------------------------------------------------------------------------
)
$set(_nTNum,$if($gt(%_nTotalDiscs%,1),%_PaddedDiscNum%-,)%_PaddedTrackNum%)

$noop(
------------------------------------------------------------------------
-  Add disambiguation, release year, label and catalog number to       -
-  the album title information as available and enabled in the         -
-  "User Settings" section.  Use the first value there is more than    -
-  one specified in the metadata.                                      -
------------------------------------------------------------------------
)
$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(
------------------------------------------------------------------------
-  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%,3))...))
$if($gt($len(%_nTNT%),%_tTitleMaxLength%),$set(_nTNT,$left(%_nTNT%,$sub(%_tTitleMaxLength%,3))...))


$noop(
########################################################################
#                                                                      #
#  Set Album Type [Single, Soundtrack, Classical, Other or Standard]   #
#                                                                      #
########################################################################
)


$noop(
------------------------------------------------------------------------
-  Set to "Soundtrack" if one of the secondary release types is        -
-  'soundtrack'.  Also add the track artist to the track title.        -
------------------------------------------------------------------------
)
$if($or($in(%_secondaryreleasetype%,soundtrack),$in(%genre%,Soundtrack)),
    $set(_nAlbumType,Soundtrack)
)

$noop(
------------------------------------------------------------------------
-  Set to "Other" if one of the secondary release types is 'other'.    -
-  Also add the track artist to the track title.                       -
------------------------------------------------------------------------
)
$if($in(%releasetype%,other),
    $set(_nAlbumType,Other)
    $set(_nFeat,%_nFTA%)
)

$noop(
------------------------------------------------------------------------
-  Set to "Classical" if one of the genres is 'Classical' and the      -
-  album type is not already set.  Also add the composer or primary    -
-  track artist to the track title.                                    -
------------------------------------------------------------------------
)
$if($and($in(%genre%,Classical),$not(%_nAlbumType%)),
    $set(_nAlbumType,Classical))

$noop(
------------------------------------------------------------------------
-  Set to "Standalone" if only one song.                               -
------------------------------------------------------------------------
)
$if($and($eq($matchedtracks(),1),$not($in(%_secondaryreleasetype%,soundtrack)),$not($in(%genre%,Soundtrack))),
    $set(_nAlbumType,Standalone),
    $set(_nFeat,$if(%_nATA%,feat. %_nATA%,)))

$noop(
------------------------------------------------------------------------
-  Set to "No Album" if no album.                                      -
------------------------------------------------------------------------
)
$if($eq(%_nAN%,%_cUnknownAlbum%),
    $set(_nAlbumType,Unknown Album))

$noop(
------------------------------------------------------------------------
-  Set to "Standard" if processing type is not already set.            -
------------------------------------------------------------------------
)
$set(_nAlbumType,$if2(%_nAlbumType%,Standard))


$noop(
##################################################################################
#                                                                                #
#  Set the file path and name in accordance with the specified processing type.  #
#                                                                                #
#  Process as Classical                                                          #
#   Format: /[Classical]/Album Artist/[year] Album/Disc-Track [Composer] Title   #
#                                                                                #
#  Process as Other                                                              #
#   Format: /[Other]/[year] Album/Disc-Track Title [Artist]                      #
#                                                                                #
#  Process as Soundtrack                                                         #
#   Format: /[Soundtrack]/[year] Album/Disc-Track Title [Artist]                 #
#                                                                                #
#  Process as Single                                                             #
#   Formats: /~ A ~/Album Artist/[~Singles~]/[year] Title [feat.]                #
#                                                                                #
#  Process as Standard                                                           #
#   Formats: /~ A ~/Album Artist/[year] Album/Disc-Track Title [feat.]           #
#            /~ # ~/Album Artist/[year] Album/Disc-Track Title [feat.]           #
#            /[Various Artists]/[year] Album/Disc-Track Title [Artist]           #
#            /[Unknown Artists]/[year] Album/Disc-Track Title [Artist]           #
#                                                                                #
##################################################################################
)

$noop(
------------------------------------------------------------------------
-  Set the file path.                                                  -
------------------------------------------------------------------------
)
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nFAAS%/%_nYear% %_nANT%/))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFilePath,%_cSoundtrack%/%_nANT% [%_nPAA%]/))
$if($eq(%_nAlbumType%,Other),$set(_nFilePath,%_cOther%/%_nYear%. %_nANT%/))
$if($eq(%_nAlbumType%,Standalone),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_nPTA%/),
        $set(_nFilePath,%_nPAA%/)))
$if($eq(%_nAlbumType%,Unknown Album),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_nPTA%/),
        $set(_nFilePath,%_nPAA%/)))
$if($eq(%_nAlbumType%,Standard),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_cVariousArtist%/%_nANT%/),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cUnknownArtistID%),%_cUnknownArtistID%),
        $set(_nFilePath,%_cUnknownArtist%/%_nANT%/))
        $set(_nFilePath,%_nPAA%/%_nYear% %_nANT%/)))


$noop(
------------------------------------------------------------------------
-  Set the file name.                                                  -
------------------------------------------------------------------------
)
$if($eq(%_nAlbumType%,Classical),$set(_nFileName,%_nTNum%. %_nTNT%))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFileName,%_nTNum%. %_nTNT% %_nFeat%))
$if($eq(%_nAlbumType%,Other),$set(_nFileName,%_nTNum%. %_nTNT%))
$if($eq(%_nAlbumType%,Standalone),
    $set(_nFileName,%_nTNT%%_nFeat% $if($or($in(%_nANT%,EP),$in(%_nANT%, \(single\))),,[%_nANT%])))
$if($eq(%_nAlbumType%,Unknown Album),$set(_nFileName,%_nTNT% %_nATA%))
$if($eq(%_nAlbumType%,Standard),$if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
    $set(_nFileName,%_nTNum%. %_nTNT% [%_nFTA%]),
    $set(_nFileName,%_nTNum%. %_nTNT% %_nFeat%)))

$noop(
------------------------------------------------------------------------
-  Trim the file name if it is longer than the maximum length set in   -
-  the "User Settings" section.                                        -
------------------------------------------------------------------------
)
$if($gt($len(%_nFileName%),%_tFilenameMaxLength%),$set(_nFileName,$left(%_nFileName%,$sub(%_tFilenameMaxLength%,3))...))


$noop(
########################################################################
#                                                                      #
#  Output the path and file name to use.                               #
#                                                                      #
########################################################################
)

$set(OutputPath,%_nFilePath%)
$set(OutputFileName,%_nFileName%)


$rreplace(%_nFilePath%/%_nFileName%,[?*:\\_]+,_)


$noop(
########################################################################
#                                                                      #
#  End of script.                                                      #
#                                                                      #
########################################################################
)

Added more character replacements.

Added naming categories for Unknown Albums and Standalone files (only one track per album) :

  • Skip album folder creation for those, instead parse album name to filename in brackets (unless EP/Single)
  • Remove track number, use primary track artist (esp useful if you have a song you could only match through Various Artists compilation, but you have only one song from this comp = it’ll use track artist instead).

Reworked categories naming :

  • Date is “2001.” instead of “[2001]”
  • If no date then nothing shows instead of [0000].
  • No initials or sortname (except on classic where i do use sortname).
  • Extended maximum lengths.

Maybe other stuff.

Now i’m gonna work on making it a genre library, not sure how i’ll go at it. Probably try to define a genre list in order that fits me, for example check for classic, then rock, then electronic etc.

Hello folks, it’s been a while since I’ve been here I was recently viewing my music folder and I wanted to change it. I’ve been searching around here and some of the old scripts I use But I haven’t found something I fancy. Just wondering if you guys have any file naming script similar to what I want something like this

Music/A/artistsname/Albums/album/tracks
I kinda want to have subfolders under each artists for things like full albums, EP, Live, Compilation and Demos

Thanks in advance for anyone who will reply
I just don’t know how to make my own script tho I tried

Is this the latest version, and is the script hosted on Github?

I have a minor issue with it, but I am not sure if I am using the latest version. For example, setting $set(_showRecordLabel,0) does not hide the record label.

You have to set the variable to an empty value:

$set(_showRecordLabel,)

or even

$unset(_showRecordLabel)
1 Like

how does one set tracks and albums that are say broudcast/dj mixes to go into a compilations folder?

I have tried

$noop(Move DJ mixes into a DJ mixes folder.)

$if($inmulti(%secondaryreleasetype%,Broadcast + DJ-mix, broadcast), compilations/,

but in the listing example below, I have a track file that has release type as broadcast and isn’t getting moved to the compilation’s folder.

Help:
I can do this

AlbumArtist/Album{Media}/discnumber - discsubtitle/Track - Title

But if i have different media i would get this (for example):

AlbumArtist/Album/Album{CD}/discnumber - discsubtitle/Track - Title
AlbumArtist/Album/Album{DVD-Video}/discnumber - discsubtitle/Track - Title
AlbumArtist/Album/Album{Blu-ray}/discnumber - discsubtitle/Track - Title

I belive that the variable that you need is _primaryreleasetype.

Hello people, i’m comming here in the hope of finding help.
I have a script that does ALMOST what i want it to except for one little thing.

$set(artist,$rreplace(%artist%,[“:<>?|],))
$set(album,$rreplace(%album%,["
:<>?|],))
$set(title,$rreplace(%title%,[”*:<>?|],))
$title($lower(
$if2(%albumartistsort%,%artistsort%,%artist%)
/
$if($if2(%albumsort%,%album%),$if2(%albumsort%,%album%), Unreleased)))
$upper($if($eq_any(%releasetype%,Album,album), [%releasetype%]))
/
$if($gt(%totaldiscs%,1),%discnumber%-,)
$if(%tracknumber%,$num(%tracknumber%,2),) - $if2(%titlesort%,%title%)

If you can see the - on the last line there’s where my issue happen.

If i have only 1 space before or after like this :

$if(%tracknumber%,$num(%tracknumber%,2),)- $if2(%titlesort%,%title%)

Song title are correct :

│ ├─ Glorryhammer/
│ │ ├─ Legends From Beyond The Galactic TerrorVortex/
│ │ │ ├─ 2-03 - Masters Of The Galaxy (Symphonic Version)

But if i have 2 space like this :

$if(%tracknumber%,$num(%tracknumber%,2),) - $if2(%titlesort%,%title%)

Song title are loses some Capital Letter :

│ ├─ Glorryhammer/
│ │ ├─ Legends From Beyond The Galactic TerrorVortex/
│ │ │ ├─ 2-03 - Masters Of The Galaxy (symphonic version)

Here what it looks like with two spaces :

And here’s with only one

I honestly don’t understand whats wrong here 0_0 and how to fix it.
If anyone here have an idea, would gladly listen.

Sorry if it was not the right place to post this.

1 Like

I wish I could help, but I’ve tried your scripts here and in every case the capitalization remained unchanged. I simply can’t get it to fail as shown in your screen shots. All I can suggest is perhaps change your last line to:

$title($if2(%titlesort%,%title%))

and see if that helps. It’s a bit of an ugly hack, but it might shed some light on what’s happening.

1 Like

I tried your suggestion.
Unfortunatly it didn’t work. For an Unknown reason it seems to be related to the -
because when i use anything else it works normally
For exemple with a .

I think i’ll just end up using 14- Song title instead of 14 - Song Title
:crossed_fingers: Just hoping plex will not get crazy cause of the -

Thanks for the Answer, and the suggestion. :slight_smile: that is greatly appreciated

@rdswift

I use your wonderful script to organize my albums and tracks but i would like to ask you if there can be some adjustments to the script?

This is the script i used.

$noop(
########################################################################
#                                                                      #
#  Picard File Naming Script                               2022-10-14  #
#  Bob Swift [rdswift]                                                 #
#                                                                      #
#  License: GPLv3.0                                                    #
#                                                                      #
########################################################################
#                                                                      #
#  This script relies on the following inputs provided by the          #
#  "Additional Artists Variables" plugin:                              #
#                                                                      #
#  Album Variables                                                     #
#                                                                      #
#      _artists_album_primary_std - The primary / first album artist   #
#               listed [standardized]                                  #
#      _artists_album_primary_sort - The primary / first album         #
#               artist listed [sort name]                              #
#      _artists_album_all_std - All album artists listed               #
#               [standardized], separated with strings provided from   #
#               the release entry                                      #
#      _artists_album_all_sort - All album artists listed              #
#               [sort names], separated with strings provided from     #
#               the release entry                                      #
#      _artists_album_all_sort_primary - The primary / first album     #
#               artist listed [sort name] followed by all additional   #
#               album artists [standardized], separated with strings   #
#               provided from the release entry                        #
#                                                                      #
#  Track Variables                                                     #
#                                                                      #
#      _artists_track_primary_cred - The primary / first track artist  #
#               listed [as credited]                                   #
#      _artists_track_additional_cred - All track artists listed [as   #
#               credited] except for the primary / first artist,       #
#               separated with strings provided from the track entry   #
#      _artists_track_all_cred - All track artists listed              #
#               [as credited], separated with strings provided from    #
#               the track entry                                        #
#                                                                      #
########################################################################
)


$noop(
########################################################################
#                                                                      #
#  User Settings:                                                      #
#                                                                      #
#  _PaddedDiscNumMinLength - Minimum length to pad disc numbers        #
#  _PaddedTrackNumMinLength - Minimum length to pad track numbers      #
#  _aTitleMaxLength - Maximum length of album title in file name       #
#  _tTitleMaxLength - Maximum length of track title in file name       #
#  _tFilenameMaxLength - Overall maximum length of track file name     #
#                                                                      #
#                                                                      #
#  Processing Flags [set to '1' to include or '' to omit]:             #
#                                                                      #
#  _aTitleReleaseYear - Add the release year to the title              #
#  _aTitleDisambig - Add the disambiguation to the title               #
#  _aTitleLabel - Add the label information to the title               #
#  _aTitleCatalog - Add the catalogue number to the title              #
#                                                                      #
########################################################################
)
$set(_PaddedDiscNumMinLength,1)
$set(_PaddedTrackNumMinLength,2)
$set(_aTitleMaxLength,200)
$set(_tTitleMaxLength,200)
$set(_tFilenameMaxLength,259)

$set(_aTitleReleaseYear,)
$set(_aTitleDisambig,)
$set(_aTitleLabel,)
$set(_aTitleCatalog,)


$noop(
########################################################################
#                                                                      #
#  Constants                                                           #
#                                                                      #
#  _cUnknownArtistID - MBID of "Unknown Artist"                        #
#  _cVariousArtistID - MBID of "Various Artists"                       #
#  _cUnknownArtist - Text to use for "Unknown Artist"                  #
#  _cVariousArtist - Text to use for "Various Artists"                 #
#  _cUnknownAlbum - Text to use for unknown album title                #
#  _cNoTitle - Text to use for unknown track title                     #
#  _cClassical - Text to use for path to classical albums              #
#  _cSoundtrack - Text to use for path to soundtrack albums            #
#  _cSingles - Text to use as album title for singles by an artist     #
#  _cOther - Text to use for path to other albums                      #
#                                                                      #
########################################################################
)
$set(_cUnknownArtistID,125ec42a-7229-4250-afc5-e057484327fe)
$set(_cVariousArtistID,89ad4ac3-39f7-470e-963a-56509c546377)
$set(_cUnknownArtist,[Unknown Artist])
$set(_cVariousArtist,[Various Artists])
$set(_cUnknownAlbum,[Unknown Album])
$set(_cNoTitle,[Unknown Title])
$set(_cClassical,[Classical])
$set(_cSoundtrack,[Soundtracks])
$set(_cOther,[Other])


$noop(
########################################################################
#                                                                      #
#  RegEx Constants                                                     #
#                                                                      #
########################################################################
)
$set(_reCaseInsensitive,\(?i\))


$noop(
########################################################################
#                                                                      #
#  Variables used for processing, set to defaults if "Additional       #
#  Artists Variables" plugin not loaded or metadata is missing:        #
#                                                                      #
#  _nFAA - All album artists [standard]                                #
#  _nPAA - Primary album artist [standard]                             #
#  _nFAAS - All album artists [sort]                                   #
#  _nPAAS - Primary album artist [sort]                                #
#  _nFAAPS - All album artists [primary artist sort]                   #
#  _nPTA - Primary track artist [credited]                             #
#  _nATA - Additional track artists [credited]                         #
#  _nFTA - All track artists [credited]                                #
#  _nAN - Album title                                                  #
#  _nANT - Album title [with additional information added later]       #
#  _nTN - Track title                                                  #
#  _nTNT - Track title [with additional information added later]       #
#                                                                      #
########################################################################
)
$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(_nTN,$if2(%title%,%_cNoTitle%))
$set(_nTNT,$if2(%title%,%_cNoTitle%))


$noop(
########################################################################
#                                                                      #
#  Replace special characters in the album and track artists used in   #
#  the output file path and name.                                      #
#                                                                      #
#  Note that some of these replacements may revert back to an          #
#  underscore because of processing for Windows compatability.         #
#                                                                      #
########################################################################
)
$foreach(_nFAA; _nFAAS; _nPAA; _nPAAS; _nFAAPS; _nPTA; _nATA; _nFTA,
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[_],•))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[*],-))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[/],\u2571))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),:, \u2236))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[?],!))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[`´‘’ʻ""“”],'))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]3,…))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]2_,…)))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[._]*\$,))

$noop(
########################################################################
#                                                                      #
#  Replace special characters in the album and track title used in     #
#  the output file path and name.                                      #
#                                                                      #
#  Note that some of these replacements may revert back to an          #
#  underscore because of processing for Windows compatability.         #
#                                                                      #
########################################################################
)
$foreach(_nAN; _nANT; _nTN; _nTNT,
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[_],•))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[*],-))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[:], \u2236))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[?],!))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[`´‘’ʻ""“”],'))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]3,…))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[.]2_,…)))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[._]*/\$],))

$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(_nInitial,~ $upper($firstalphachar(%_nFAAPS%,#)) ~/)

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

$noop(
------------------------------------------------------------------------
-  Calculate the maximum lengths for disc and track numbers and set    -
-  the desired padding lengths.                                        -
------------------------------------------------------------------------
)
$set(_TotalDiscNumberLength,$len($if2(%totaldiscs%,1)))
$set(_TotalTrackNumberLength,$len($if2(%totaltracks%,1)))
$set(_DiscPadLength,$if($gt(%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%),%_TotalDiscNumberLength%,%_PaddedDiscNumMinLength%))
$set(_TrackPadLength,$if($gt(%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%),%_TotalTrackNumberLength%,%_PaddedTrackNumMinLength%))

$noop(
------------------------------------------------------------------------
-  Automatically pad disc and track numbers to the length of the       -
-  total number of discs and tracks.                                   -
------------------------------------------------------------------------
)
$set(_PaddedDiscNum,$num($if2(%discnumber%,1),%_DiscPadLength%))
$set(_PaddedTrackNum,$num($if2(%tracknumber%,1),%_TrackPadLength%))

$noop(
------------------------------------------------------------------------
-  Set the year for the release                                        -
------------------------------------------------------------------------
)
$set(_nYear,
	$if($gt($left($if2(%originaldate%,%originalyear%,%date%),4),1400),
	$left($if2(%originaldate%,%originalyear%,%date%),4).))

$noop(
------------------------------------------------------------------------
-  Add the disc number to the track number if there is more than one   -
-  disc in the album.                                                  -
------------------------------------------------------------------------
)
$set(_nTNum,$if($gt(%_nTotalDiscs%,1),%_PaddedDiscNum%-,)%_PaddedTrackNum%)

$noop(
------------------------------------------------------------------------
-  Add disambiguation, release year, label and catalog number to       -
-  the album title information as available and enabled in the         -
-  "User Settings" section.  Use the first value there is more than    -
-  one specified in the metadata.                                      -
------------------------------------------------------------------------
)
$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(
------------------------------------------------------------------------
-  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%,3))...))
$if($gt($len(%_nTNT%),%_tTitleMaxLength%),$set(_nTNT,$left(%_nTNT%,$sub(%_tTitleMaxLength%,3))...))


$noop(
########################################################################
#                                                                      #
#  Set Album Type [Single, Soundtrack, Classical, Other or Standard]   #
#                                                                      #
########################################################################
)


$noop(
------------------------------------------------------------------------
-  Set to "Soundtrack" if one of the secondary release types is        -
-  'soundtrack'.  Also add the track artist to the track title.        -
------------------------------------------------------------------------
)
$if($or($in(%_secondaryreleasetype%,soundtrack),$in(%genre%,Soundtrack)),
    $set(_nAlbumType,Soundtrack)
)

$noop(
------------------------------------------------------------------------
-  Set to "Other" if one of the secondary release types is 'other'.    -
-  Also add the track artist to the track title.                       -
------------------------------------------------------------------------
)
$if($in(%releasetype%,other),
    $set(_nAlbumType,Other)
    $set(_nFeat,%_nFTA%)
)

$noop(
------------------------------------------------------------------------
-  Set to "Classical" if one of the genres is 'Classical' and the      -
-  album type is not already set.  Also add the composer or primary    -
-  track artist to the track title.                                    -
------------------------------------------------------------------------
)
$if($and($in(%genre%,Classical),$not(%_nAlbumType%)),
    $set(_nAlbumType,Classical))

$noop(
------------------------------------------------------------------------
-  Set to "Standalone" if only one song.                               -
------------------------------------------------------------------------
)
$if($and($eq($matchedtracks(),1),$not($in(%_secondaryreleasetype%,soundtrack)),$not($in(%genre%,Soundtrack))),
    $set(_nAlbumType,Standalone),
    $set(_nFeat,$if(%_nATA%,feat. %_nATA%,)))

$noop(
------------------------------------------------------------------------
-  Set to "No Album" if no album.                                      -
------------------------------------------------------------------------
)
$if($eq(%_nAN%,%_cUnknownAlbum%),
    $set(_nAlbumType,Unknown Album))

$noop(
------------------------------------------------------------------------
-  Set to "Standard" if processing type is not already set.            -
------------------------------------------------------------------------
)
$set(_nAlbumType,$if2(%_nAlbumType%,Standard))


$noop(
##################################################################################
#                                                                                #
#  Set the file path and name in accordance with the specified processing type.  #
#                                                                                #
#  Process as Classical                                                          #
#   Format: /[Classical]/Album Artist/[year] Album/Disc-Track [Composer] Title   #
#                                                                                #
#  Process as Other                                                              #
#   Format: /[Other]/[year] Album/Disc-Track Title [Artist]                      #
#                                                                                #
#  Process as Soundtrack                                                         #
#   Format: /[Soundtrack]/[year] Album/Disc-Track Title [Artist]                 #
#                                                                                #
#  Process as Single                                                             #
#   Formats: /~ A ~/Album Artist/[~Singles~]/[year] Title [feat.]                #
#                                                                                #
#  Process as Standard                                                           #
#   Formats: /~ A ~/Album Artist/[year] Album/Disc-Track Title [feat.]           #
#            /~ # ~/Album Artist/[year] Album/Disc-Track Title [feat.]           #
#            /[Various Artists]/[year] Album/Disc-Track Title [Artist]           #
#            /[Unknown Artists]/[year] Album/Disc-Track Title [Artist]           #
#                                                                                #
##################################################################################
)

$noop(
------------------------------------------------------------------------
-  Set the file path.                                                  -
------------------------------------------------------------------------
)
$if($eq(%_nAlbumType%,Classical),$set(_nFilePath,%_cClassical%/%_nFAAS%/%_nYear% %_nANT%/))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFilePath,%_cSoundtrack%/%_nANT% [%_nPAA%]/))
$if($eq(%_nAlbumType%,Other),$set(_nFilePath,%_cOther%/%_nYear%. %_nANT%/))
$if($eq(%_nAlbumType%,Standalone),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_nPTA%/),
        $set(_nFilePath,%_nPAA%/)))
$if($eq(%_nAlbumType%,Unknown Album),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_nPTA%/),
        $set(_nFilePath,%_nPAA%/)))
$if($eq(%_nAlbumType%,Standard),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
        $set(_nFilePath,%_cVariousArtist%/%_nANT%/),
    $if($eq($if2(%musicbrainz_albumartistid%,%_cUnknownArtistID%),%_cUnknownArtistID%),
        $set(_nFilePath,%_cUnknownArtist%/%_nANT%/))
        $set(_nFilePath,%_nPAA%/%_nYear% %_nANT%/)))


$noop(
------------------------------------------------------------------------
-  Set the file name.                                                  -
------------------------------------------------------------------------
)
$if($eq(%_nAlbumType%,Classical),$set(_nFileName,%_nTNum%. %_nTNT%))
$if($eq(%_nAlbumType%,Soundtrack),$set(_nFileName,%_nTNum%. %_nTNT% %_nFeat%))
$if($eq(%_nAlbumType%,Other),$set(_nFileName,%_nTNum%. %_nTNT%))
$if($eq(%_nAlbumType%,Standalone),
    $set(_nFileName,%_nTNT%%_nFeat% $if($or($in(%_nANT%,EP),$in(%_nANT%, \(single\))),,[%_nANT%])))
$if($eq(%_nAlbumType%,Unknown Album),$set(_nFileName,%_nTNT% %_nATA%))
$if($eq(%_nAlbumType%,Standard),$if($eq($if2(%musicbrainz_albumartistid%,%_cVariousArtistID%),%_cVariousArtistID%),
    $set(_nFileName,%_nTNum%. %_nTNT% [%_nFTA%]),
    $set(_nFileName,%_nTNum%. %_nTNT% %_nFeat%)))

$noop(
------------------------------------------------------------------------
-  Trim the file name if it is longer than the maximum length set in   -
-  the "User Settings" section.                                        -
------------------------------------------------------------------------
)
$if($gt($len(%_nFileName%),%_tFilenameMaxLength%),$set(_nFileName,$left(%_nFileName%,$sub(%_tFilenameMaxLength%,3))...))


$noop(
########################################################################
#                                                                      #
#  Output the path and file name to use.                               #
#                                                                      #
########################################################################
)

$set(OutputPath,%_nFilePath%)
$set(OutputFileName,%_nFileName%)


$rreplace(%_nFilePath%/%_nFileName%,[?*:\\_]+,_)


$noop(
########################################################################
#                                                                      #
#  End of script.                                                      #
#                                                                      #
########################################################################
)``

I would like it to be this way

The name of the artist

year and album name

and then within the album:
Artist name - track number - trackname

I tried to make some adjustments to your script but i messed things up.
That’s why i ask you if you could make the adjustment to the script accordingly
i appreciate your help. Thanks in advance

Is this the album artist or track artist? Primary artist only, or full list of artists? Also should they be standardized or as credited? Note that these may be different for some tracks, and will definitely be different on a “Various Artists” release. I assume that you don’t want the sorted name.

Again, is this the album artist or track artist? Primary artist only, or full list of artists? Standardized or as credited? Again I assume you don’t want the sort name.

To which types of releases should this be applied? Currently the script uses different formats for Classical, Sountrack, Single, Standard and Other. My assumption is that you only want to apply this to Standard.

Finally, I suggest that you edit your original post to put ```taggerscript (three backticks followed by the text “taggerscript”) on a separate line just before the script starts and ``` (three backticks) on a separate line immediately following the script. This will display it as code including scroll bars as required, and will not format it strangely. For example, writing it as:

```taggerscript
This is a line of the script.
```

will display as:

This is a line of the script.

@rdswift

I did what you advise. I hope its readable now.
The reason i asked you is that i am using Filebot, and it works fine with how i want my album name and tracks to display.

Yes i only want to apply it to standard
The first name is the album artist and the name you see before in the track number and name is the track artist

I use Filebot and for {n} they put the name of the artist
In my Filebot script, i also use media composer.

your script is fine except a few changes that i would like
After you click the artist name i would like to see [1972] - Let’s Stay Together instead of 1972. Let’s Stay Together.
And when you click on the album i would like to see artist’s name followed by the track number and track name.

Since you don’t appear to need all the features of my file naming script, it would probably be easier to just start with a new (simpler) script than try to modify the existing script.

Try something like:

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

I also suggest that you take a look at the Writing a File Naming Script tutorial to see what it is doing.

1 Like

Thank you very much.

I can’t say that i don’t need the features of your script. What I’m trying to say is that i use Filebot for my album renaming, but i also need Music Brainz for the rest of my album processing. Therefore i would like both Filebot and MusicBrainz to have the same naming convention. That will avoid problems and a corrupt library, which was the case this week. I use MusicBrainz with a different naming script that someone posted on this site and it completely messed up my music library.
Your script was the one that comes close to what the naming script i used in Filebot was doing.

Having said that, i wonder if i can use MusicBrainz to automatically rename and reorder my library if i add new albums to my music library? Something like a Watch status.

Hi rdswift,

I tried the basic script that you posted and it looks like it satisfied my needs.

I only missed one thing in the scripts and that is the selection of a CD

Here you can see what i mean:

Brenda Lee/[1995] - Litle Miss Dynamite/CD3/Brenda Lee - 11 - Around The World.flac

If i use your script i don’t see the CD section

I think i found a solution to put the CD into my script

$if2(%albumartist%,%artist%) - /[$left($if2(%date%,%originaldate%,0000),4)] - %album%/%media% $if2(%discnumber%,1)/%artist% - $num(%tracknumber%,2) - %title%

I trying to figure out how i can adjust the script in a way that if it there is no CD that section would be empty.