Skip to content

Instantly share code, notes, and snippets.

@devhawk
Created June 23, 2012 20:53
Show Gist options
  • Select an option

  • Save devhawk/2979933 to your computer and use it in GitHub Desktop.

Select an option

Save devhawk/2979933 to your computer and use it in GitHub Desktop.
get-bitrate powershell function
function get-bitrate( $file) {
$shell = New-Object -ComObject Shell.Application
$dir = $shell.NameSpace($file.Directory.FullName)
$fileObj = $dir.parseName($file.Name)
$bitrateAttribute = 0
for( $index = 5; -not $bitrateAttribute; ++$index ) {
$name = $directoryObject.GetDetailsOf( $dir.Items, $index )
if( $name -eq 'Bit rate' ) { $bitrateAttribute = $index }
}
$dir.GetDetailsOf( $fileObj, $bitrateAttribute )
}
@ranger69
Copy link

Line 8 required a change for this to work. Additionally, the file parameter required a Get-ChildItem call

Line 8 change from:


  $name = $directoryObject.GetDetailsOf( $dir.Items, $index )

Line 8 changed to:


  $name = $dir.GetDetailsOf( $dir.Items, $index )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment