Created
June 9, 2019 16:34
-
-
Save r15ch13/5b9db753315853d4a5985fe932f7c0b9 to your computer and use it in GitHub Desktop.
Revisions
-
r15ch13 created this gist
Jun 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ function Read-AudioBookChecksum { param( [Parameter(Mandatory=$true, Position=0, ParameterSetName="Path", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [ValidateScript({ Test-Path $_ -Type Leaf })] [string] $Path ) Process { try { $buffer = New-Object Byte[] 20 $fs = [IO.File]::OpenRead($Path) $fs.Seek(581, [System.IO.SeekOrigin]::Begin) | Out-Null $fs.Read($buffer, 0, 4) | Out-Null if([System.Text.Encoding]::UTF8.GetString($buffer) -eq 'adrm') { $fs.Seek(653, [System.IO.SeekOrigin]::Begin) | Out-Null $fs.Read($buffer, 0, 20) | Out-Null return ($buffer | ForEach-Object ToString x2) -join '' } return $null } finally { $fs.Close(); } } } Get-ChildItem "*.aax" | Read-AudioBookChecksum $_