how to read ID3v2 tag in powershell?

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.

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"

Write-host "Loading the following DLL" $ScriptDirectory


Add-Type -Path $ScriptDirectory

#[Reflection.Assembly]::LoadFrom( (Resolve-Path "$ScriptDirectory"))


foreach ($file in  Get-ChildItem -Path "D:\Deep House" -Include *.mp3 -File -Recurse){

 $media = [TagLib.MPEG.File]::Create($file)

 write-host $file.Fullname 


Write-Host $media.Tag.BeatsPerMinute
Write-Host $media.Tag.

# need header TKEY Initial key

#$test = [TagLib.Id3v2.Header] ??????

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


$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