Call me...




Monday, July 27, 2020

Query metatags, no extenal DLL's, or exe's needed.

This is my most recent discovery for auditing multiple audio file metatags...
These files are the back-up of my iPod

There's a lot more here than is needed - But I wanted it to look nice.

There is also plenty of comments and methods in it, to give you an idea on what kind of audits are possible.

Previously, I used ffprobe (part of ffmpeg) to read these tags... But it was kinds of slow...
What I used here, took less than half the time.

To see what I did with that "$NullQuery" from this script, see this post:
http://www.somethingtoscrollthrough.com/2020/07/command-line-search-ms.html


$NullQuery = @()
$NullCount = 0
$StartTime = (Get-Date)

$DrivesInfo = Get-WmiObject -Class Win32_logicaldisk
Write-Host "===========================" -ForegroundColor Cyan
$AudioSource = "$(($DrivesInfo | ? {$_.VolumeName -match "easystore"}).DeviceID)\iPod BackUp\iPod_Control\Music"
$_TitlesCounter = 0

$_Titles = $null
$_Titles = gci $AudioSource -Recurse -Force | ? {($_.Name -match ".m4a") -or ($_.Name -match ".mp3")}
$_TitlesTotal = $_Titles.Count

$_Titles | % {
$_TitlesCounter++

$path = $_.FullName # 'F:\iPod BackUp\iPod_Control\Music\F00\GNVD.mp3'
$shell = New-Object -COMObject Shell.Application
$folder = $_.DirectoryName  # Split-Path $path
$file = $_.Name  # Split-Path $path -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)

$Label_Array = @(13,14,16,20,21,26,27,194,237)  | % { '{0} = {1}' -f $_, $shellfolder.GetDetailsOf($null, $_) }

$Label_Array | % {
$Set_Up = (($_).Split('=')).Split("`n|`r",[System.StringSplitOptions]::RemoveEmptyEntries)
#Write-Host  "$($Set_Up[1]): $($shellfolder.GetDetailsOf($shellfile, $Set_Up[0]))"
$Tag__ = ($Set_Up[1]).Trim()
$Tag__Value = $shellfolder.GetDetailsOf($shellfile, $Set_Up[0])

    $_FullName = ($path).ToUpper()

    If ( $Tag__ -eq "Authors") {
    $artist01 = "ARTIST"
    $artist02 = $Tag__Value
        If ($artist02 -eq "") {$artist02 = "NULL"}
    }

    If ( $Tag__ -eq "Title") {
    $title01 = ($Tag__).ToUpper()
    $title02 = $Tag__Value
        If ($title02 -eq "") {$title02 = "NULL"}
    }

    If ( $Tag__ -eq "Album") {
    $album01 = ($Tag__).ToUpper()
    $album02 = $Tag__Value
        If ($album02 -eq"") {$album02 = "NULL"}
    }

    If ( $Tag__ -eq "Album artist") {
    $albumArtist01 = ($Tag__).ToUpper()
    $albumArtist02 = $Tag__Value
        If ($albumArtist02 -eq "") {$albumArtist02 = "NULL"}
    }

    If ( $Tag__ -eq "#") {
    $track01 = "TRACK"
    $track02 = $Tag__Value
        If ($track02 -eq "") {$track02 = "NULL"}
    }

    If ( $Tag__ -eq "genre") {
    $genre01 = ($Tag__).ToUpper()
    $genre02 = $Tag__Value
        If ($genre02 -eq "") {$genre02 = "NULL"}
    }

} # END $Label_Array | %
##########################
    Write-Host "$_FullName" -ForegroundColor Cyan
        Write-Host "        $artist01`: " -NoNewline -ForegroundColor Yellow; Write-Host $artist02
        Write-Host "  $albumArtist01`: " -NoNewline -ForegroundColor Yellow; Write-Host $albumArtist02
        Write-Host "         $title01`: " -NoNewline -ForegroundColor Yellow; Write-Host $title02              
        Write-Host "         $album01`: " -NoNewline -ForegroundColor Yellow; Write-Host $album02
        Write-Host "         $track01`: " -NoNewline -ForegroundColor Yellow; Write-Host $track02
        Write-Host "         $genre01`: " -NoNewline -ForegroundColor Yellow; Write-Host $genre02
        Write-Host "===== Timer: $(((Get-Date) - $StartTime).Minutes) minutes ====== Total: $_TitlesCounter of $_TitlesTotal / Null: $NullCount" -ForegroundColor Green

        If (($artist02 -eq "NULL") -or ($title02 -eq "NULL")) {
        $NullCount++
        $QueryB = new-object psobject
        $QueryB | Add-Member -membertype noteproperty -name "FilePath" -Value $_FullName
        $QueryB | Add-Member -membertype noteproperty -name "File" -Value $file
        $QueryB | Add-Member -membertype noteproperty -name "Folder" -Value $folder
        $QueryB | Add-Member -membertype noteproperty -name "Artist" -Value $artist02
        $QueryB | Add-Member -membertype noteproperty -name "Album_Artist" -Value $albumArtist02
        $QueryB | Add-Member -membertype noteproperty -name "Title" -Value $title02
        $QueryB | Add-Member -membertype noteproperty -name "Album" -Value $album02
        $QueryB | Add-Member -membertype noteproperty -name "Track" -Value $track02
        $NullQuery += $QueryB
        Write-Host "#####################################" -ForegroundColor Magenta
        Start-Sleep -Milliseconds 1500
        }
Clear-Variable artist*
Clear-Variable title*
Clear-Variable album*
Clear-Variable track*
Clear-Variable genre*
##########################
}