Find mp3 files with low Bit Rate

Here’s a function to find all folders containing mp3 files (listed if ‘-details’ switch is used) with a bit rate under the threshold (128kbps by default)

function Get-LowMp3([string]$folder=".",[int]$minBitrate=128,[switch]$details=$false) {
$shellObject=New-Object -ComObject Shell.Application

$mp3s=Get-ChildItem $folder -Recurse -Filter '*.mp3'
ForEach($mp3 in $mp3s) {
    # Get a shell object to retrieve file metadata.

    # Find the index of the bit rate attribute.
    For($index=5; -Not $bitrateAttrib;++$index) {
        if($name -eq 'Bit rate') { $bitrateAttrib=$index }

    # Get the bit rate of the file.
    if($bitrateString -match '\d+') { [int]$bitrate=$matches[0] }
    else { $bitrate=-1 }

    # Include the file in the results if it has the desired bit rate.
    if($bitrate -le $minBitrate) { 
        if ($details) { $mp3 } else { $directoryObject }

Leave a Reply

Scroll to Top