I am using the macro below to get the length (run time) of video and/or audio files in a selected directory. It works great if the files are in a sub-directory (e.g. "D:\Videos"), but for some reason, it does list the length attribute if the video/audio files are in the root directory of the specified drive (e.g. "D:"). It will list the file names, but not the length attribute. Any ideas why? Thanks.
Sub GetDetails()
Dim oShell As Object
Dim oFile As Object
Dim oFldr As Object
Dim lRow As Long
Dim iCol As Integer
Dim vArray As Variant
vArray = Array(0, 27)
'27 = length
Set oShell = CreateObject("Shell.Application")
lRow = 1
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select the Folder..."
If .Show Then
Set oFldr = oShell.Namespace(.SelectedItems(1))
With oFldr
For iCol = LBound(vArray) To UBound(vArray)
Cells(lRow, iCol + 1) = .GetDetailsOf(.Items, vArray(iCol))
Next iCol
For Each oFile In .Items
Select Case UCase(Right(oFile, 4)) 'limit extensions listed line below
Case ".AVI", ".MP3", ".MP4", ".MPG", ".MOV", ".WMV", ".FLV", ".M4A", ".WAV", ".WMA", ".MKV", ".3gp", ".m4v", "mpeg"
lRow = lRow + 1
For iCol = LBound(vArray) To UBound(vArray)
Cells(lRow, iCol + 1) = .GetDetailsOf(oFile, vArray(iCol))
Next iCol
End Select 'End extension limitation
Next oFile
End With
End If
End With
End Sub
Bookmarks