Two Extra Spaces coming from Nowhere. Why?

On this script, near the bottom where I have the Record Label in the directory name, "Disk 1 [Record Label Here]

I’m getting two extra spaces between the 1 and the […

It probably has something to do with the way that the this area near the bottom:

))$noop(
   )$if(%_nameForDiscFolder%,%_nameForDiscFolder%)
   )$if(%_showRecordLabel%,$noop(2 extra spaces are Getting Added Here if this is true. Why?)[%label%]
)/ 

It seems odd that if I put a closing parenthesis after [%label%] then gives a syntax error. But if I don’t it works, or if I take that whole line out, it works. So… it’s parathesis voodoo somewhere. Otherwise I actually learned quite a bit off messing with this thing for the past few hours. So something good came of it, I just don’t want the bonus spaces.

$noop(★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★)
$noop(★ MBP Magic-Script - v0.4.2                                            ★)
$noop(★                                                                      ★)
$noop(★ Here is a script for music renaming in MusicBrainz Picard            ★)
$noop(★                                                                      ★)
$noop(★ Features :                                                           ★)
$noop(★ - Organize root music folder with last.fm category OR artist initial ★)
$noop(★ - Can use custom subfolder for each main type [Album/Single/EP...]   ★)
$noop(★ - Can use custom subfolder for compilation [!various]                ★)
$noop(★ - Exclude type album from using subfolder                            ★)
$noop(★ - Custom folder for soundtrack/various                               ★)
$noop(★ - Alphabetize artist without leading "The"                           ★)
$noop(★ - Improve tag displaying on some device                              ★)
$noop(★ - Filtered character for files & folders naming                      ★)
$noop(★ - Include media type in folder name [when its not CD]                ★)
$noop(★ - Subfolder for multi-disc [setting to disable subfolder]            ★)
$noop(★ - Custom folder tag for multi-disc CD/Vinyl [CD1/Disc1 by default]   ★)
$noop(★ - Put multi-CD release in same folder [naming become 101/102/201...] ★)
$noop(★ - Vinyl can use musicbrainz style for track [A1/A2/B1...]            ★)
$noop(★   Put incomplete in separate album named folder                      ★)
$noop(★   Added subfolder for type [video]                                   ★)
$noop(★   Lossy / Lossless at root directory DISABLED in favor of type folder★)
$noop(★ - Custom settings                                                    ★)
$noop(★                                                                      ★)
$noop(★ Needed :                                                             ★)
$noop(★ - Last.fm.ng plugin [for category trending]                          ★)
$noop(★   -> https://github.com/fdemmer/Picard-Last.fm.ng-Plugin             ★)
$noop(★                                                                      ★)
$noop(★  Plugin for is_lossless / is_lossy                                   ★)
$noop(★ https://community.metabrainz.org/t/categorizing-lossless-music/258530★)
$noop(★                                                                      ★)
$noop(★                                                                      ★)
$noop(★ Happy tagging!!!                                                     ★)
$noop(★                                                                      ★)
$noop(★----------------------------------------------------------------------★)
$noop(★  ★ By 17500mph ★                                                    ★)
$noop(★  ★ Original By Ski-lleR ★ It's the same overall flow but            ★)
$noop(★   with some re-arrangements and additional categorical type folders  ★)
$noop(★----------------------------------------------------------------------★)
$noop(★                                                                      ★)
$noop(★ Thanks to                                                            ★)
$noop(★                                                                      ★)
$noop(★ avibrazil for his filter                                             ★)
$noop(★ > https://github.com/avibrazil/picard-scripting                      ★)
$noop(★                                                                      ★)
$noop(★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★)

$noop(######################### SETTINGS #########################)

$noop(★ GLOBAL ★)
$set(_separateByTypeInArtistFolder,1)
$set(_separateAlbum,0)
$set(_useMusicBrainzStyleForVinylTrack,1)
$set(_showRecordLabel,1)

$noop(★ Multi-Disc ★)
$set(_useSubDiscFolder,1)
$set(_mergeDiscWhenNotUsingSubfolder,0)
$set(_showDiscSubtitle,1)
$set(_nameForTypeCD,Disc)
$set(_nameForTypeVinyl,Side)

$noop(★ orderTypeForRoot ★)
$noop(★  1: Category [Last.fm.ng] ★)
$noop(★  2: Artist first letter ★)
$set(_orderTypeForRoot,2)

$noop(★ orderTypeForArtist ★)
$noop(★  1: First letter of first name ★)
$noop(★  2: First letter of last name ★)
$set(_orderTypeForArtist,2)

$noop(★ CUSTOM SUBFOLDER BY TYPE ★)
$set(_albumSubFolder,Album/)
$set(_liveSubFolder,Live/)
$set(_singlesSubFolder,Single/)
$set(_epSubFolder,EP/)
$set(_broadcastSubFolder,Broadcast/)
$set(_videoSubFolder,Video/)
$set(_lossySubFolder,MP3/)
$set(_losslessSubFolder,Flac/)
$set(_otherSubFolder,Others/)
$set(_extFolder,%_extension%/)
$set(_serialSubFolder,Serials/)

$noop(★ COMPILATION FOLDER [NO VARIOUS] ★)
$set(_compilationsSubFolder,Compilation/)

$noop(★ SOUNDTRACK/VARIOUS FOLDER ★)
$set(_soundTracksFolder,Soundtrack/)
$set(_variousArtistsFolder,Various/)
$set(_audiobooksFolder,Audiobook/)
$set(_incompleteFolder,Partial/)

$noop(####################### END SETTINGS #######################)


$noop(########## PATH SAMPLE [with defaults settings] ############)

$noop(★ 1st level ★)
$noop(~/Music/SoundTracks)
$noop(~/Music/Various)
$noop(~/Music/Category)

$noop(★ 2nd level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl])
$noop(~/Music/Various/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The)

$noop(★ 3rd level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Various/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Compilations)
$noop(~/Music/Category/Artist, The/Singles)
$noop(~/Music/Category/Artist, The/EP)
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl])

$noop(★ 4th level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Various/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl]/CD1~subtitle)

$noop(★ 5eme level ★)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)

$noop(★ 6eme level ★)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)


$noop(########## DETECT MUSIC TYPE ###############################)

$noop(★ Detect Album ★)
$if($in(%releasetype%,album),
  $set(_isAlbum,1)
)

$noop(★ Detect Single ★)
$if($in(%releasetype%,single),
  $set(_isSingle,1)
)

$noop(★ Detect EP ★)
$if($in(%releasetype%,ep),
  $set(_isEP,1)
)

$noop(★ Detect Broadcast ★)
$if($in(%releasetype%,broadcast),
  $set(_isBroadcast,1)
)

$noop(★ Detect Audiobook ★)
$if($in(%releasetype%,audiobook),
  $set(_isAudiobook,1)
)

$noop(★ Detect Other ★)
$if($in(%releasetype%,other),
  $set(_isOther,1)
)

$noop(★ Detect Artist Compilation ★)
$if($in(%releasetype%,compilation),
  $set(_isArtistCompil,1)
)

$noop(★ Detect Live ★)
$if($in(%releasetype%,live),
  $set(_isLive,1)
)

$noop(★ Detect Soundtrack ★)
$if($in(%releasetype%,soundtrack),
  $set(_isSoundTrack,1)
)
$noop(★ Detect Incomplete ★)
$if($eq($is_complete(),0),
  $set(_isIncomplete,1)
)

$noop(★ Detect Video ★)
$if($eq($is_video(),0),
  $set(_isVideo,1)
)

$noop(★ Detect Various Artist ★)
$if($eq(%albumartist%,Various Artists),
  $set(_isVarious,1)
)

$noop(★ Re-detect Compilation ★)
$if($eq(%compilation%,1),
  $set(_isGlobalCompil,1)
)


$noop(########## TAG MANAGE ######################################)

$noop(★ Organize artist by alphabetical folders excluding leading The ★)
$set(albumartist,$if($eq($left(%albumartist%,4),The ),%albumartistsort%,%albumartist%))


$noop(########## TAG CLEANUP  ####################################)

$noop(★ Typography for tags: changes will affect tags on media ★)

$noop(★ ... ➡ …)
$set(album,$replace(%album%,...,…))
$set(title,$replace(%title%,...,…))
$set(discsubtitle,$replace(%discsubtitle%,...,…))

$noop(★ No. ➡ №)
$set(album,$replace(%album%, [Nn]o.\\s*\(\\d\), №\\1))
$set(title,$rreplace(%title%, [Nn]o.\\s*\(\\d\), №\\1))
$set(discsubtitle,$replace(%discsubtitle%, [Nn]o.\\s*\(\\d\), №\\1))

$noop(★ [digit]" ➡ [digit]″)
$set(discsubtitle,$rreplace(%discsubtitle%,\(\\d\)",\\1''))

$noop(★ "12" Vinyl" ➡ "12 Inch Vinyl")
$set(media,$rreplace(%media%,\(\\d\)",\\1 Inch))
$set(album,$rreplace(%album%,\(\\d\)",\\1 Inch))
$set(title,$rreplace(%title%,\(\\d\)",\\1 Inch))

$noop(★ "something" ➡ “something” single quote for server/samba)
$set(albumartist,$rreplace(%albumartist%,"\(.*?\)",'\\1'))
$set(artist,$rreplace(%artist%,"\(.*?\)",'\\1'))
$set(albumartistsort,$rreplace(%albumartistsort%,"\(.*?\)",'\\1'))
$set(artistsort,$rreplace(%artistsort%,"\(.*?\)",'\\1'))
$set(album,$rreplace(%album%,"\(.*?\)",'\\1'))
$set(title,$rreplace(%title%,"\(.*?\)",'\\1'))
$set(discsubtitle,$rreplace(%discsubtitle%,"\(.*?\)",'\\1'))



$noop(★ Typography on file naming only ★)

$set(_titleForFilename,%title%)
$set(_albumForFilename,%album%)
$set(_discsubtitleForFilename,%discsubtitle%)
$set(_albumartistForFilename,%albumartist%)
$set(_artistForFilename,%artist%)
$set(_albumartistsortForFilename,%albumartistsort%)
$set(_artistsortForFilename,%artistsort%)

$noop(★ # ➡ ♯)
$set(_titleForFilename,$replace(%_titleForFilename%,#,♯))
$set(_albumForFilename,$replace(%_albumForFilename%,#,♯))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,#,♯))

$noop(★ : ➡ ∶)
$set(_titleForFilename,$replace(%_titleForFilename%,:,∶))
$set(_albumForFilename,$replace(%_albumForFilename%,:,∶))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,:,∶))
$set(_artistForFilename,$replace(%_artistForFilename%,:,∶))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,:,∶))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,:,∶))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,:,∶))

$noop(★ ? ➡ ⁇)
$set(_titleForFilename,$replace(%_titleForFilename%,?,⁇))
$set(_albumForFilename,$replace(%_albumForFilename%,?,⁇))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,?,⁇))
$set(_artistForFilename,$replace(%_artistForFilename%,?,⁇))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,?,⁇))

$set(_titleForFilename,$replace(%_titleForFilename%,|,│))
$set(_albumForFilename,$replace(%_albumForFilename%,|,│))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,|,│))

$set(_titleForFilename,$replace(%_titleForFilename%,>,>))
$set(_albumForFilename,$replace(%_albumForFilename%,>,>))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,>,>))

$set(_titleForFilename,$replace(%_titleForFilename%,<,<))
$set(_albumForFilename,$replace(%_albumForFilename%,<,<))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,<,<))

$set(_titleForFilename,$replace(%_titleForFilename%,*,✱))
$set(_albumForFilename,$replace(%_albumForFilename%,*,✱))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,*,✱))
$set(_artistForFilename,$replace(%_artistForFilename%,*,✱))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,*,✱))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,*,✱))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,*,✱))

$set(_titleForFilename,$replace(%_titleForFilename%,&,&))
$set(_albumForFilename,$replace(%_albumForFilename%,&,&))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,&,&))
$set(_artistForFilename,$replace(%_artistForFilename%,&,&))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,&,&))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,&,&))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,&,&))

$noop(########## RENAMER CORE ####################################)
$noop(Prefix Begins Here with root value set im Prefs)
$upper(%_extension%/)
$noop(root+extension)

$noop(★ Separate Lossy/Lossess types at root directory - Requires plugin ★)
$noop($if($is_lossless(),%_losslessSubFolder%,%_lossySubFolder%/))
$noop(root+extension+[if_enambled]Lossiness)

$noop(★ Soundtrack in custom directory ★)
$if(%_isAudiobook%,%_audiobooksFolder%,)

$if(%_isSoundTrack%,%_soundTracksFolder%,

  $noop(★ Various in custom directory ★)
  $if(%_isVarious%,%_variousArtistsFolder%,

$noop(★ Order root by category ★)
$if($eq(%_orderTypeForRoot%,1),
  $if2(%albumgrouping%,Unknown)
)/

$noop(★ Order root by artist ★)
$if($eq(%_orderTypeForRoot%,2),

  $if($eq(%_orderTypeForArtist%,1),
    $upper($firstalphachar($if2(%_albumartistForFilename%, %_artistForFilename%),#)),
  $if($eq(%_orderTypeForArtist%,2),
    $upper($firstalphachar($if2(%_albumartistsortForFilename%, %_artistsortForFilename%),#))
  ))
)/
$noop(root+extension+[if_enambled]Lossiness/First Sort)

$noop(★ Artist with first letter of first name ★)
$if($eq(%_orderTypeForArtist%,1),
  $if2(%_albumartistForFilename%,%_artistForFilename%)
)/

$noop(★ Artist with first letter of last name ★)
$if($eq(%_orderTypeForArtist%,2),
  $if2(%_albumartistsortForFilename%,%_artistsortForFilename%)
)/

$noop(★ Organize by type ★)
$if($eq(%_separateByTypeInArtistFolder%,1),
  $if($or(%_isArtistCompil%,%_isGlobalCompil%),%_compilationsSubFolder%,
    $if($eq(%_isLive%,1),%_liveSubFolder%,
      $if($eq(%_isAlbum%,1),
        $if($eq(%_separateAlbum%,1),%_albumSubFolder%)
        )
        $if($eq(%_isSingle%,1),%_singlesSubFolder%)
        $if($eq(%_isEP%,1),%_epSubFolder%)
        $if($eq(%_isBroadcast%,1),%_broadcastSubFolder%)
        $if($eq(%_isVideo%,1),%_videoSubFolder%)
        $if($eq(%_isOther%,1),%_otherSubFolder%)
      )
    )
  )
)
  )


$noop(★ Album - YEAR [Media-Type][CDx~subtitle]/ or /CDx~subtitle/ ★)

$if($if2(%date%,%originalyear%,%originaldate%),$left([$if2(%date%,%originalyear%,%originaldate%),5)] ,0000)


%_albumForFilename% 

$noop($if($ne(%media%,CD), $if(%media%,[$rreplace(%media%,["″], Inch)])))
$if($ne(%media%,CD), $if(%media%,[%media%]))


$set(_numbr,$left(%_bitrate%,3))
$noop($set(_numbr,$div(%_bitrate%,1000)) )

$if($eq(%_bitrate%,320.0),$set(_filebr,320),
$if($eq(%_bitrate%,256.0),$set(__filebr,256),
$if($eq(%_bitrate%,224.0),$set(__filebr,224),
$if($eq(%_bitrate%,192.0),$set(__filebr,192),
$if($eq(%_bitrate%,160.0),$set(__filebr,160),
$if($eq(%_bitrate%,128.0),$set(__filebr,128),
$if($eq(%_bitrate%,112.0),$set(__filebr,112),
$if($eq(%_bitrate%,96.0),$set(__filebr,96),
$if($eq(%_bitrate%,80.0),$set(__filebr,80),
$if($eq(%_bitrate%,64.0),$set(__filebr,64),
$if($eq(%_bitrate%,56.0),$set(__filebr,56),
$if($eq(%_bitrate%,48.0),$set(__filebr,48),
$if($eq(%_bitrate%,40.0),$set(__filebr,40),
$if($eq(%_bitrate%,32.0),$set(__filebr,32),
$if($eq(%_bitrate%,24.0),$set(__filebr,24),
$if($eq(%_bitrate%,16.0),$set(__filebr,16),
$if($eq(%_bitrate%,8.0),$set(__filebr,8))))))))))))))))))

$noop($set(_folderbr,Vrb) )

$set(_folderbr,%_numbr%)

$if(%_folderbr%,,
$if($gte(%_numbr%,320),$set(_folderbr,320+),
$if($eq(%_numbr%,320),$set(_folderbr,320),
$if($lt(%_numbr%,319),$set(_folderbr,256),
$if($lt(%_numbr%,255),$set(_folderbr,192),
$if($lt(%_numbr%,191),$set(_folderbr,128),
$if($lt(%_numbr%,127),$set(_folderbr,96),
$if($lt(%_numbr%,96),$set(_folderbr,48),
))))))))

$if($eq($upper(%_extension%),MP3),[%_folderbr%K %_sample_rate% %_channels%])

$noop(★ Incomplete in custom directory ★)
$if(%_isIncomplete%,- %_incompleteFolder%/,)

$if($gt(%totaldiscs%,1),$noop(
  )$if($lt(%totaldiscs%,10),$set(_discnumber, %discnumber%),$set(_discnumber,$num(%discnumber%,2)))$noop(
  )$if($in(%media%,Vinyl),$noop(
)$set(_nameForDiscFolder,@OSLASH@@OBRACKET@%_nameForTypeVinyl%%_discnumber%@CBRACKET@),$noop(
)$set(_nameForDiscFolder,@OSLASH@@OBRACKET@%_nameForTypeCD%%_discnumber%@CBRACKET@))$noop(
)$if($and(%_discsubtitleForFilename%,$eq(%_showDiscSubtitle%,1)),$set(_nameForDiscFolder,%_nameForDiscFolder% - %_discsubtitleForFilename%))$noop(
)$if($eq(%_useSubDiscFolder%,1),$noop(
  )$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@OSLASH@@OBRACKET@,/))$noop(
  )$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@CBRACKET@,)),$noop(
  )$if($eq(%_mergeDiscWhenNotUsingSubfolder%,1),$noop(
    )$unset(_nameForDiscFolder),$noop(
    )$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@OSLASH@@OBRACKET@,[))$noop(
   )$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@CBRACKET@,]))$noop(
  ))$noop(
))$noop(
   )$if(%_nameForDiscFolder%,%_nameForDiscFolder%)
   )$if(%_showRecordLabel%,$noop(2 extra spaces are Getting Added Here if this is true. Why?)[%label%]
)/

$noop(★ Track. Title ★)
$if($in(%media%,Vinyl),$noop(
  )$if($eq(%_useMusicBrainzStyleForVinylTrack%,1),$noop(
)$if(%_musicbrainz_tracknumber%,%_musicbrainz_tracknumber%. )$noop(
  )),$noop(
  )$if(%tracknumber%,$if($gt(%totaldiscs%,1),$if($and($eq(%_useSubDiscFolder%,0),$eq(%_mergeDiscWhenNotUsingSubfolder%,1)),%discnumber%))$num(%tracknumber%,2). )
)

$noop(Final Filename)
%_titleForFilename% $if($eq($upper(%_extension%),MP3), [%__filebr%K %_sample_rate% %_channels%])

The scripting is very sensitive to whitespace as it basically serves as a template where certain variables gets replaced. Whitespace is literally used.

$noop(
   )$if(%_nameForDiscFolder%,%_nameForDiscFolder%)
   )$if(%_showRecordLabel%,[%label%]
)/

There are spaces before )$if(%_showRecordLabel%. One solution is to write all in one line:

$noop(
   )$if(%_nameForDiscFolder%,%_nameForDiscFolder%)
)$if(%_showRecordLabel%,[%label%])/

Or you use the noop trick the script is using elsewhere:

$noop(
   )$if(%_nameForDiscFolder%,%_nameForDiscFolder%)$noop(
   ))$if(%_showRecordLabel%,[%label%])/
3 Likes

Another way to do the indents is to use tabs instead of spaces.

3 Likes

That did it. I was thinking it was something along those lines. I move the cursor around and add a couple characters here and there to see what it affects on the string at the bottom. But I didn’t clue in on the indent stuff, and I had thought of redoing it with tabs previously because I was getting bored with tapping the spaces in. If I had done that… :wink:

I have since done so. :slight_smile:
The example script output down below is one of the best features too. I can’t imagine how sucky this would be if you had to make a change, shut the prefs, save a file, go look, not what you want, wash, rinse, repeat.

(Which I suspect is one reason that I don’t like doing complex handling with Beets, but it makes a great unattended first pass tool.

A couple other things remaining:
In the generated example at the bottom of the window, the [] bracket set where I have %label%
On the top example line,

/Volumes/3TB/MBP Sorted/MP3/Soundtrack/[1965] Help! [K ] - Partial/[]/07. Ticket to Ride [K ].mp3

There is a leading / added in there that I presume would cause there to be a directory that is just the Record Label. I can’t find the source of that. The line below it is forming the example in the desired mannor. ( …- Beat Up []/05…] vs …- Partial/[]/07. Ticket…)

On the second example line, where is the ‘VA’ coming from, and I presume it’s in the ‘V’ directory because of the album artist name setting. What I’d really like to have is for that /Compilation to be at the same level as the alphabetical directories, and not in the ‘V’ directory at all. Everything else is how I want it.

The otherwise cleaned up, tabbed version of the script is below.
Thanks! :+1:

$noop(★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★)
$noop(★ MBP Magic-Script - v0.4.2                                            ★)
$noop(★                                                                      ★)
$noop(★ Here is a script for music renaming in MusicBrainz Picard            ★)
$noop(★                                                                      ★)
$noop(★ Features :                                                           ★)
$noop(★ - Organize root music folder with last.fm category OR artist initial ★)
$noop(★ - Can use custom subfolder for each main type [Album/Single/EP...]   ★)
$noop(★ - Can use custom subfolder for compilation [!various]                ★)
$noop(★ - Exclude type album from using subfolder                            ★)
$noop(★ - Custom folder for soundtrack/various                               ★)
$noop(★ - Alphabetize artist without leading "The"                           ★)
$noop(★ - Improve tag displaying on some device                              ★)
$noop(★ - Filtered character for files & folders naming                      ★)
$noop(★ - Include media type in folder name [when its not CD]                ★)
$noop(★ - Subfolder for multi-disc [setting to disable subfolder]            ★)
$noop(★ - Custom folder tag for multi-disc CD/Vinyl [CD1/Disc1 by default]   ★)
$noop(★ - Put multi-CD release in same folder [naming become 101/102/201...] ★)
$noop(★ - Vinyl can use musicbrainz style for track [A1/A2/B1...]            ★)
$noop(★   Put incomplete in separate album named folder                      ★)
$noop(★   Added subfolder for type [video]                                   ★)
$noop(★   Lossy / Lossless at root directory DISABLED in favor of type folder★)
$noop(★ - Custom settings                                                    ★)
$noop(★                                                                      ★)
$noop(★ Needed :                                                             ★)
$noop(★ - Last.fm.ng plugin [for category trending]                          ★)
$noop(★   -> https://github.com/fdemmer/Picard-Last.fm.ng-Plugin             ★)
$noop(★                                                                      ★)
$noop(★  Plugin for is_lossless / is_lossy                                   ★)
$noop(★ https://community.metabrainz.org/t/categorizing-lossless-music/258530★)
$noop(★                                                                      ★)
$noop(★                                                                      ★)
$noop(★ Happy tagging!!!                                                     ★)
$noop(★                                                                      ★)
$noop(★----------------------------------------------------------------------★)
$noop(★  ★ By 17500mph ★                                                     ★)
$noop(★  ★ Original By Ski-lleR ★ It's the same overall flow but             ★)
$noop(★   with some re-arrangements and additional categorical type folders  ★)
$noop(★----------------------------------------------------------------------★)
$noop(★                                                                      ★)
$noop(★ Thanks to                                                            ★)
$noop(★                                                                      ★)
$noop(★ avibrazil for his filter                                             ★)
$noop(★ > https://github.com/avibrazil/picard-scripting                      ★)
$noop(★                                                                      ★)
$noop(★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★)

$noop(######################### SETTINGS #########################)

$noop(★ GLOBAL ★)
$set(_separateByTypeInArtistFolder,1)
$set(_separateAlbum,0)
$set(_useMusicBrainzStyleForVinylTrack,1)
$set(_showRecordLabel,1)

$noop(★ Multi-Disc ★)
$set(_useSubDiscFolder,1)
$set(_mergeDiscWhenNotUsingSubfolder,0)
$set(_showDiscSubtitle,1)
$set(_nameForTypeCD,Disc)
$set(_nameForTypeVinyl,Side)

$noop(★ orderTypeForRoot ★)
$noop(★  1: Category [Last.fm.ng] ★)
$noop(★  2: Artist first letter ★)
$set(_orderTypeForRoot,2)

$noop(★ orderTypeForArtist ★)
$noop(★  1: First letter of first name ★)
$noop(★  2: First letter of last name ★)
$set(_orderTypeForArtist,2)

$noop(★ CUSTOM SUBFOLDER BY TYPE ★)
$set(_albumSubFolder,Album/)
$set(_liveSubFolder,Live/)
$set(_singlesSubFolder,Single/)
$set(_epSubFolder,EP/)
$set(_broadcastSubFolder,Broadcast/)
$set(_videoSubFolder,Video/)
$set(_lossySubFolder,MP3/)
$set(_losslessSubFolder,Flac/)
$set(_otherSubFolder,Others/)
$set(_extFolder,%_extension%/)
$set(_serialSubFolder,Serials/)

$noop(★ COMPILATION FOLDER [NO VARIOUS] ★)
$set(_compilationsSubFolder,Compilation/)

$noop(★ SOUNDTRACK/VARIOUS FOLDER ★)
$set(_soundTracksFolder,Soundtrack/)
$set(_variousArtistsFolder,Various/)
$set(_audiobooksFolder,Audiobook/)
$set(_incompleteFolder,Partial/)

$noop(####################### END SETTINGS #######################)


$noop(########## PATH SAMPLE [with defaults settings] ############)

$noop(★ 1st level ★)
$noop(~/Music/SoundTracks)
$noop(~/Music/Various)
$noop(~/Music/Category)

$noop(★ 2nd level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl])
$noop(~/Music/Various/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The)

$noop(★ 3rd level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Various/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Compilations)
$noop(~/Music/Category/Artist, The/Singles)
$noop(~/Music/Category/Artist, The/EP)
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl])

$noop(★ 4th level ★)
$noop(~/Music/SoundTracks/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Various/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl])
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl]/CD1~subtitle)

$noop(★ 5eme level ★)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl]/CD1~subtitle)
$noop(~/Music/Category/Artist, The/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)

$noop(★ 6eme level ★)
$noop(~/Music/Category/Artist, The/Compilations/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/Singles/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)
$noop(~/Music/Category/Artist, The/EP/Album name - 2016 [Vinyl]/CD1~subtitle/01. Track.flac)


$noop(########## DETECT MUSIC TYPE ###############################)

$noop(★ Detect Album ★)
$if($in(%releasetype%,album),
  $set(_isAlbum,1)
)

$noop(★ Detect Single ★)
$if($in(%releasetype%,single),
  $set(_isSingle,1)
)

$noop(★ Detect EP ★)
$if($in(%releasetype%,ep),
  $set(_isEP,1)
)

$noop(★ Detect Broadcast ★)
$if($in(%releasetype%,broadcast),
  $set(_isBroadcast,1)
)

$noop(★ Detect Audiobook ★)
$if($in(%releasetype%,audiobook),
  $set(_isAudiobook,1)
)

$noop(★ Detect Other ★)
$if($in(%releasetype%,other),
  $set(_isOther,1)
)

$noop(★ Detect Artist Compilation ★)
$if($in(%releasetype%,compilation),
  $set(_isArtistCompil,1)
)

$noop(★ Detect Live ★)
$if($in(%releasetype%,live),
  $set(_isLive,1)
)

$noop(★ Detect Soundtrack ★)
$if($in(%releasetype%,soundtrack),
  $set(_isSoundTrack,1)
)
$noop(★ Detect Incomplete ★)
$if($eq($is_complete(),0),
  $set(_isIncomplete,1)
)

$noop(★ Detect Video ★)
$if($eq($is_video(),0),
  $set(_isVideo,1)
)

$noop(★ Detect Various Artist ★)
$if($eq(%albumartist%,Various Artists),
  $set(_isVarious,1)
)

$noop(★ Re-detect Compilation ★)
$if($eq(%compilation%,1),
  $set(_isGlobalCompil,1)
)


$noop(########## TAG MANAGE ######################################)

$noop(★ Organize artist by alphabetical folders excluding leading The ★)
$set(albumartist,$if($eq($left(%albumartist%,4),The ),%albumartistsort%,%albumartist%))


$noop(########## TAG CLEANUP  ####################################)

$noop(★ Typography for tags: changes will affect tags on media ★)

$noop(★ ... ➡ …)
$set(album,$replace(%album%,...,…))
$set(title,$replace(%title%,...,…))
$set(discsubtitle,$replace(%discsubtitle%,...,…))

$noop(★ No. ➡ №)
$set(album,$replace(%album%, [Nn]o.\\s*\(\\d\), №\\1))
$set(title,$rreplace(%title%, [Nn]o.\\s*\(\\d\), №\\1))
$set(discsubtitle,$replace(%discsubtitle%, [Nn]o.\\s*\(\\d\), №\\1))

$noop(★ [digit]" ➡ [digit]″)
$set(discsubtitle,$rreplace(%discsubtitle%,\(\\d\)",\\1''))

$noop(★ "12" Vinyl" ➡ "12 Inch Vinyl")
$set(media,$rreplace(%media%,\(\\d\)",\\1 Inch))
$set(album,$rreplace(%album%,\(\\d\)",\\1 Inch))
$set(title,$rreplace(%title%,\(\\d\)",\\1 Inch))

$noop(★ "something" ➡ “something” single quote for server/samba)
$set(albumartist,$rreplace(%albumartist%,"\(.*?\)",'\\1'))
$set(artist,$rreplace(%artist%,"\(.*?\)",'\\1'))
$set(albumartistsort,$rreplace(%albumartistsort%,"\(.*?\)",'\\1'))
$set(artistsort,$rreplace(%artistsort%,"\(.*?\)",'\\1'))
$set(album,$rreplace(%album%,"\(.*?\)",'\\1'))
$set(title,$rreplace(%title%,"\(.*?\)",'\\1'))
$set(discsubtitle,$rreplace(%discsubtitle%,"\(.*?\)",'\\1'))



$noop(★ Typography on file naming only ★)

$set(_titleForFilename,%title%)
$set(_albumForFilename,%album%)
$set(_discsubtitleForFilename,%discsubtitle%)
$set(_albumartistForFilename,%albumartist%)
$set(_artistForFilename,%artist%)
$set(_albumartistsortForFilename,%albumartistsort%)
$set(_artistsortForFilename,%artistsort%)

$noop(★ # ➡ ♯)
$set(_titleForFilename,$replace(%_titleForFilename%,#,♯))
$set(_albumForFilename,$replace(%_albumForFilename%,#,♯))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,#,♯))

$noop(★ : ➡ ∶)
$set(_titleForFilename,$replace(%_titleForFilename%,:,∶))
$set(_albumForFilename,$replace(%_albumForFilename%,:,∶))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,:,∶))
$set(_artistForFilename,$replace(%_artistForFilename%,:,∶))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,:,∶))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,:,∶))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,:,∶))

$noop(★ ? ➡ ⁇)
$set(_titleForFilename,$replace(%_titleForFilename%,?,⁇))
$set(_albumForFilename,$replace(%_albumForFilename%,?,⁇))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,?,⁇))
$set(_artistForFilename,$replace(%_artistForFilename%,?,⁇))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,?,⁇))

$set(_titleForFilename,$replace(%_titleForFilename%,|,│))
$set(_albumForFilename,$replace(%_albumForFilename%,|,│))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,|,│))

$set(_titleForFilename,$replace(%_titleForFilename%,>,>))
$set(_albumForFilename,$replace(%_albumForFilename%,>,>))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,>,>))

$set(_titleForFilename,$replace(%_titleForFilename%,<,<))
$set(_albumForFilename,$replace(%_albumForFilename%,<,<))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,<,<))

$set(_titleForFilename,$replace(%_titleForFilename%,*,✱))
$set(_albumForFilename,$replace(%_albumForFilename%,*,✱))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,*,✱))
$set(_artistForFilename,$replace(%_artistForFilename%,*,✱))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,*,✱))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,*,✱))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,*,✱))

$set(_titleForFilename,$replace(%_titleForFilename%,&,&))
$set(_albumForFilename,$replace(%_albumForFilename%,&,&))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,&,&))
$set(_artistForFilename,$replace(%_artistForFilename%,&,&))
$set(_albumartistForFilename,$replace(%_albumartistForFilename%,&,&))
$set(_artistsortForFilename,$replace(%_artistsortForFilename%,&,&))
$set(_albumartistsortForFilename,$replace(%_albumartistsortForFilename%,&,&))

$noop(########## RENAMER CORE ####################################)
$noop(Prefix Begins Here with root value set im Prefs)
$upper(%_extension%/)
$noop(root+extension)

$noop(★ Separate Lossy/Lossess types at root directory - Requires plugin ★)
$noop(	$if($is_lossless(),%_losslessSubFolder%,%_lossySubFolder%/))

$noop(root+extension+[if_enambled]Lossiness)

$noop(★ Soundtrack in custom directory ★)

$if(%_isSoundTrack%,%_soundTracksFolder%,
$if(%_isAudiobook%,%_audiobooksFolder%,)

	$noop(★ Various in custom directory ★)
	$if(%_isVarious%,%_variousArtistsFolder%,

		$noop(★ Order root by category ★)
		$if($eq(%_orderTypeForRoot%,1),
		$if2(%albumgrouping%,Unknown)
		)/

	$noop(★ Order root by artist ★)
	$if($eq(%_orderTypeForRoot%,2),

		$if($eq(%_orderTypeForArtist%,1),
			$upper($firstalphachar($if2(%_albumartistForFilename%, %_artistForFilename%),#)),
		$if($eq(%_orderTypeForArtist%,2),
			$upper($firstalphachar($if2(%_albumartistsortForFilename%, %_artistsortForFilename%),#))
		))
	)/

$noop(root+extension+[if_enambled]Lossiness/First Sort)

	$noop(★ Artist with first letter of first name ★)
	$if($eq(%_orderTypeForArtist%,1),
	$if2(%_albumartistForFilename%,%_artistForFilename%)
	)/

	$noop(★ Artist with first letter of last name ★)
	$if($eq(%_orderTypeForArtist%,2),
	$if2(%_albumartistsortForFilename%,%_artistsortForFilename%)
	)/

	$noop(★ Organize by type ★)
	$if($eq(%_separateByTypeInArtistFolder%,1),
		$if($or(%_isArtistCompil%,%_isGlobalCompil%),%_compilationsSubFolder%,
			$if($eq(%_isLive%,1),%_liveSubFolder%,
				$if($eq(%_isAlbum%,1),
					$if($eq(%_separateAlbum%,1),%_albumSubFolder%)
					)
					$if($eq(%_isSingle%,1),%_singlesSubFolder%)
					$if($eq(%_isEP%,1),%_epSubFolder%)
					$if($eq(%_isBroadcast%,1),%_broadcastSubFolder%)
					$if($eq(%_isVideo%,1),%_videoSubFolder%)
					$if($eq(%_isOther%,1),%_otherSubFolder%)
				)
			)
		)
	)
)

$noop(★ Album - YEAR [Media-Type][CDx~subtitle]/ or /CDx~subtitle/ ★)
$if($if2(%date%,%originalyear%,%originaldate%),$left([$if2(%date%,%originalyear%,%originaldate%),5)] ,0000)

%_albumForFilename% 
$noop($if($ne(%media%,CD), $if(%media%,[$rreplace(%media%,["″], Inch)])))
$if($ne(%media%,CD),$if(%media%,[%media%]))


$set(_numbr,$left(%_bitrate%,3))
$noop($set(_numbr,$div(%_bitrate%,1000)) )

$if($eq(%_bitrate%,320.0),$set(_filebr,320),
$if($eq(%_bitrate%,256.0),$set(__filebr,256),
$if($eq(%_bitrate%,224.0),$set(__filebr,224),
$if($eq(%_bitrate%,192.0),$set(__filebr,192),
$if($eq(%_bitrate%,160.0),$set(__filebr,160),
$if($eq(%_bitrate%,128.0),$set(__filebr,128),
$if($eq(%_bitrate%,112.0),$set(__filebr,112),
$if($eq(%_bitrate%,96.0),$set(__filebr,96),
$if($eq(%_bitrate%,80.0),$set(__filebr,80),
$if($eq(%_bitrate%,64.0),$set(__filebr,64),
$if($eq(%_bitrate%,56.0),$set(__filebr,56),
$if($eq(%_bitrate%,48.0),$set(__filebr,48),
$if($eq(%_bitrate%,40.0),$set(__filebr,40),
$if($eq(%_bitrate%,32.0),$set(__filebr,32),
$if($eq(%_bitrate%,24.0),$set(__filebr,24),
$if($eq(%_bitrate%,16.0),$set(__filebr,16),
$if($eq(%_bitrate%,8.0),$set(__filebr,8))))))))))))))))))

$noop($set(_folderbr,Vrb))

$set(_folderbr,%_numbr%)
$if(%_folderbr%,,
$if($gte(%_numbr%,320),$set(_folderbr,320+),
$if($eq(%_numbr%,320),$set(_folderbr,320),
$if($lt(%_numbr%,319),$set(_folderbr,256),
$if($lt(%_numbr%,255),$set(_folderbr,192),
$if($lt(%_numbr%,191),$set(_folderbr,128),
$if($lt(%_numbr%,127),$set(_folderbr,96),
$if($lt(%_numbr%,96),$set(_folderbr,48),
))))))))$if($eq($upper(%_extension%),MP3),[%_folderbr%K %_sample_rate% %_channels%] )

$noop(★ Incomplete in custom directory ★)
$if(%_isIncomplete%,- %_incompleteFolder%,)

$if($gt(%totaldiscs%,1),$noop(
	)$if($lt(%totaldiscs%,10),$set(_discnumber, %discnumber%),$set(_discnumber,$num(%discnumber%,2)))$noop(
	)$if($in(%media%,Vinyl),$noop(
		)$set(_nameForDiscFolder,@OSLASH@@OBRACKET@%_nameForTypeVinyl%%_discnumber%@CBRACKET@),$noop(
		)$set(_nameForDiscFolder,@OSLASH@@OBRACKET@%_nameForTypeCD%%_discnumber%@CBRACKET@))$noop(
		)$if($and(%_discsubtitleForFilename%,$eq(%_showDiscSubtitle%,1)),$set(_nameForDiscFolder,%_nameForDiscFolder% - %_discsubtitleForFilename%))$noop(
		)$if($eq(%_useSubDiscFolder%,1),$noop(
			)$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@OSLASH@@OBRACKET@,/))$noop(
			)$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@CBRACKET@,)),$noop(
			)$if($eq(%_mergeDiscWhenNotUsingSubfolder%,1),$noop(
				)$unset(_nameForDiscFolder),$noop(
				)$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@OSLASH@@OBRACKET@,[))$noop(
			)$set(_nameForDiscFolder,$replace(%_nameForDiscFolder%,@CBRACKET@,]))$noop(
		))$noop(
	))$noop(
	)$if(%_nameForDiscFolder%,%_nameForDiscFolder%))$if(%_showRecordLabel%, [%label%])/

$noop(★ Track. Title ★)
$if($in(%media%,Vinyl),$noop(
	)$if($eq(%_useMusicBrainzStyleForVinylTrack%,1),$noop(
		)$if(%_musicbrainz_tracknumber%,%_musicbrainz_tracknumber%. )$noop(
	)),$noop(
	)$if(%tracknumber%,$if($gt(%totaldiscs%,1),$if($and($eq(%_useSubDiscFolder%,0),$eq(%_mergeDiscWhenNotUsingSubfolder%,1)),%discnumber%))$num(%tracknumber%,2). )
)

$noop(Final Filename)
%_titleForFilename% $if($eq($upper(%_extension%),MP3),[%__filebr%K %_sample_rate% %_channels%])
1 Like