Skip to content

Instantly share code, notes, and snippets.

@wqweto
Last active January 4, 2016 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wqweto/8574945 to your computer and use it in GitHub Desktop.
Save wqweto/8574945 to your computer and use it in GitHub Desktop.
Dumps audio file bitrate
@echo off
for /f "tokens=1-2 delims=|" %%i in ('cscript //nologo bitrate.vbs /f:"%~1" /m:"%~2"') do (
if %%j LSS 320 echo %%i has bitrate %%j and will be deleted
)
sFolder = WScript.Arguments.Named("f")
sMask = WScript.Arguments.Named("m")
If LenB(sFolder) = 0 Then
WScript.echo "usage: " & WScript.ScriptName & " /f:folder [/m:mask]"
WScript.Quit 1
End If
If LenB(sMask) = 0 Then
sMask = "mp3"
End If
Set oFileMatch = New RegExp
oFileMatch.IgnoreCase = True
If Left(sMask, 1) = "/" Then
oFileMatch.Pattern = Mid(sMask, 2)
Else
oFileMatch.Pattern = "\." & Replace(sMask, ".", vbNullString) & "$"
End If
Set oBitRateStrip = New RegExp
oBitRateStrip.Global = True
oBitRateStrip.Pattern = "[^\d]"
GetBitrate CreateObject("Shell.Application").Namespace(sFolder)
Function GetBitrate(oFolder)
For Each oFile In oFolder.Items
If oFile.IsFolder Then
GetBitrate oFile.GetFolder
ElseIf oFileMatch.Test(oFile.Name) Then
sBitRate = oBitRateStrip.Replace(oFolder.GetDetailsOf(oFile, 28), vbNullString)
If LenB(sBitRate) <> 0 Then
WScript.echo oFile.Path & "|" & sBitRate
End If
End If
Next
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment