Advertisement
Guest User

Get Media Info

a guest
Nov 12th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Clear-Host
  2.  
  3. $Files = Get-ChildItem -Path "D:\Media\Movies" -Exclude "*.ps1","*.srt" -Recurse
  4. $CSVFile = "C:\Temp\MediaInfo.csv" #Use $null if you don't want to export to CSV
  5.  
  6. $objTemplate = New-Object psobject
  7. $objTemplate | Add-Member -MemberType NoteProperty -Name FileName -Value $null
  8. $objTemplate | Add-Member -MemberType NoteProperty -Name FullPath -Value $null
  9. $objTemplate | Add-Member -MemberType NoteProperty -Name Width -Value $null
  10. $objTemplate | Add-Member -MemberType NoteProperty -Name Height -Value $null
  11. $objTemplate | Add-Member -MemberType NoteProperty -Name BitRate_kbps -Value $null
  12.  
  13. $objResult = @()
  14. $i = 1
  15.  
  16. foreach($File in $Files) {
  17.    $PercComplete = ($i / $Files.Count) * 100
  18.    Write-Progress -Activity "Getting info.." -Status "Getting information for $($File.Name) ($i/$($Files.Count))" -PercentComplete $PercComplete
  19.    
  20.    #Update the location of the MediaInfo.exe
  21.    $Info = C:\Users\Shayne\Desktop\MediaInfo_CLI\MediaInfo.exe "--Inform=Video;%Width%,%Height%,%BitRate%" $File.FullName
  22.  
  23.    $objTemp = $objTemplate | Select-Object *
  24.    $objTemp.FileName = $File.Name
  25.    $objTemp.FullPath = $File.FullName
  26.    $objTemp.Width = $Info.Split(",")[0]
  27.    $objTemp.Height = $Info.Split(",")[1]
  28.    $objTemp.BitRate_kbps = [int](($Info.Split(",")[2]) / 1024)
  29.    $objResult += $objTemp
  30.    $i++
  31. }
  32.  
  33. $objResult | Format-Table -AutoSize
  34.  
  35. if ($CSVFile) {
  36.    $objResult | Export-Csv -Path $CSVFile -NoTypeInformation -Force
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement