Help - Make " be 'inch' (12" --> 12 Inch) in this script

filenaming
tagger-script
Tags: #<Tag:0x00007f11cb599de8> #<Tag:0x00007f11cb599a28>

#1

I’ve cobbled together bits of a few scripts into one, managed to get it to do a few things I want, the last being I’d like to have places where it’s making it say [12" Vinyl] be written as [12 Inch Vinyl] instead.

I just can’t seem to figure out in here where it may be doing any of that, or for that matter, what to rreplace with what, and where:

Right now I get
MP3\Depeche Mode\Violator - 1990 [12" Vinyl] [256K 44100 2]

I’d like it to be:
MP3\Depeche Mode\Violator - 1990 [12 Inch Vinyl] [256K 44100 2]

$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 artist/cat root path                    ★)
$noop(★   Added subfolder for type [video]                                   ★)
$noop(★   Separate Lossy / Lossless at root directory                        ★)
$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 Ski-lleR ★ w/mods by 17500mph                           ★)
$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,0)

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

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

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

$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(album,$rreplace(%album%,\(\\d\)",\\1″))
$set(discsubtitle,$rreplace(%discsubtitle%,\(\\d\)",\\1″))

$noop(★ "something" ➡ “something”)
$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 ####################################)


$upper(%_extension%/)
$noop(★ Incomplete in custom directory ★)
$if(%_isIncomplete%,%_incompleteFolder%/,)
$noop(★ Separate Lossy/Lossess types at root directory - Requires plugin ★)
$noop($if($is_lossless(),%_losslessSubFolder%,%_lossySubFolder%/))
$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(★ 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/ ★)


%_albumForFilename% - 

$if($if2(%date%,%originalyear%,%originaldate%),$left($if2(%date%,%originalyear%,%originaldate%),4),0000)
$if($ne(%media%,CD), $if(%media%,[%media%]))



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

$if($eq(%_bitrate%,320.0),$set(_folderbr,320),
$if($eq(%_bitrate%,256.0),$set(_folderbr,256),
$if($eq(%_bitrate%,192.0),$set(_folderbr,192),
$if($eq(%_bitrate%,160.0),$set(_folderbr,160),
$if($eq(%_bitrate%,128.0),$set(_folderbr,128),
$if($eq(%_bitrate%,64.0),$set(_folderbr,64)))))))
$if(%_folderbr%,,
$if($gte(%_numbr%,220),$set(_folderbr,V0),
$if($lt(%_numbr%,220),$set(_folderbr,V2),
$set(_folderbr,Err1)
)))
$if($eq($upper(%_extension%),MP3), [%_folderbr%K %_sample_rate% %_channels%])

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

$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). )
)
 %_titleForFilename%

#2

While we’re in this topic, shouldn’t the inch symbol be using the proper double prime symbol (″) instead of the double quotation mark (")?


#3

What you are looking for is the %media% variable, this holds the format of the medium, e.g. “CD” or “12” Vinyl". And indeed, if you look at your script you will find this snippet where this variable is used:

$if($ne(%media%,CD), $if(%media%,[%media%]))

Now this maybe looks a bit more complicated than it is. The basic idea that it will output something like “[12” Vinyl]" only if %media% is neither “CD” nor empty.

Now you have to replace the " character with " Inch", for this you can use the $replace function like this:

$replace(%media%,", Inch)

In your script you would use this only on the variable the gets actually ouput:

$if($ne(%media%,CD), $if(%media%,[$replace(%media%,", Inch)]))

That should work for your case.

Now @Jeluang makes a good point about the use of double prime instead of double quotation mark ". Maybe someone decides to change this for the media names in the future, so as an extra let’s make the script future proof to work with both:

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

This is using $rreplace instead of $replace. $rreplace allows you to use “regular expressions”. This is a bit too much to explain here, but basically you can use regular expressions to describe specific patterns of text. In our case we use a group ["″] that matches both the quotation mark and double prime character.


#4

Perfect, thanks! :slight_smile:

I’ve tried similar where I’ve got it checking for quotes in either %album% or %title%, to do the same thing, where there is an " in the title that isn’t part of a set of them for author names or similar.

Not having any success there either.