FYI: I have updated my VBS file "duration.vbs". It now reads the wave header to calculate the file duration. This means that it will correctly deal with files that are not 16 bit 44100Hz stereo. Unfortunately it will still fail if files have additional RIFF chunks (which most don't).
This can be used as a method to create the list of file durations - just put the file in the "source" folder and double-click.
Dim objFSO, objFolder, objFile, objOutput
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("./")
Set objOutput = objFSO.OpenTextFile("duration.txt.tmp", 2, True)
For Each objFile in objFolder.Files
If GetExtension(objFile.Name) = ".wav" Then
objOutput.WriteLine(GetWaveDuration(objFile.Name))
End If
Next
objOutput.Close
Set objOutput = Nothing
Set objFile = Nothing
If objFSO.FileExists("duration.txt") Then objFSO.DeleteFile "duration.txt"
objFSO.MoveFile "duration.txt.tmp", "duration.txt"
Set objFSO = Nothing
Function GetExtension(ByVal strFile)
GetExtension = LCase(Mid(strFile, InstrRev(strFile, ".")))
End Function
Function GetWaveDuration(ByVal strFile)
Dim objSource, objBytes
Set objSource = CreateObject("ADODB.Stream")
objSource.Type = 1
objSource.Open
objSource.LoadFromFile strFile
objBytes = objSource.Read(44)
objSource.Close
Set objSource = Nothing
GetWaveDuration = Round(Binary2Integer(objBytes, 41, 44)/Binary2Integer(objBytes, 29, 32), 7)
End Function
Function Binary2Integer(Binary, intStart, intEnd)
Dim i
For i = intStart To intEnd
Binary2Integer = Binary2Integer + AscB(MidB(Binary, i, 1)) * (2 ^ ((i - intStart) * 8))
Next
End Function