how to read ID3v2 tag in powershell?

Welcome Forums General PowerShell Q&A how to read ID3v2 tag in powershell?

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
8 months, 1 week ago.

  • Author
    Posts
  • #95525

    Participant
    Points: 0
    Rank: Member

    Hi there,

    I'm currently using taglib.dll to view and work with a mp3 files attributes, essentially I'm
    creating a script that will go through a collection of mp3 files and sort them via key signature.
    Would any one know how to retrieve the "TKEY Initial key" header using taglib? I was able to get the BPM though.

    I don't quite understand how to get TKEY from the below link.
    http://taglib.org/api/classTagLib_1_1ID3v2_1_1TextIdentificationFrame.html

    My script thus far

    
    # Load the assembly. I used a relative path so I could off using the Resolve-Path cmdlet 
    
    $ScriptDirectory = (gi $PSCommandPath).DirectoryName
    $ScriptDirectory += "\taglib-sharp.dll"
    
    
    cls
    Write-host "Loading the following DLL" $ScriptDirectory
    
    pause
    
    Add-Type -Path $ScriptDirectory
    
    #[Reflection.Assembly]::LoadFrom( (Resolve-Path "$ScriptDirectory"))
    
    [Reflection.Assembly]::LoadFile($ScriptDirectory)
    pause
    cls
    
    
    foreach ($file in  Get-ChildItem -Path "D:\Deep House" -Include *.mp3 -File -Recurse){
    
    
    
     $media = [TagLib.MPEG.File]::Create($file)
    
     write-host $file.Fullname 
    
     
    }
     pause
    
    
    
    Write-Host $media.Tag.BeatsPerMinute
    Write-Host $media.Tag.
    
    #http://taglib.org/api/classTagLib_1_1ID3v2_1_1TextIdentificationFrame.html
    # need header TKEY Initial key
    
    #$test = [TagLib.Id3v2.Header] ??????
    
    
  • #95840

    Participant
    Points: 4
    Rank: Member

    It's been a while since I played with TagLib but I got it working as below:

    [Reflection.Assembly]::LoadFile('E:\temp\taglib-sharp-2.1.0.0-windows\Libraries\taglib-sharp.dll')
    
    $file = "E:\Music\Mashups\Robin Skouteris - The Moonlight Hotel Beethoven + Eagles + Maria Callas.mp3"
    
    $media = [TagLib.MPEG.File]::Create($file)
    
    $tags = $media.GetTag('Id3v2')
    
    $tags.GetFrames('TKEY') | Select-Object -ExpandProperty Text
    
    

The topic ‘how to read ID3v2 tag in powershell?’ is closed to new replies.