You need to do this:
- Mark and copy the code you see further down.
- Open your .vbs file for editing.
- Delete all existing content.
- Paste the code.
- Save and close the .vbs file.
- Use File Explorer to locate your Music folder.
- Grab the music folder with your left mouse button, then drop it on the .vbs file. You need to aim carefully. If you miss the .vbs file then File Explorer will copy your Music folder to the desktop (which you do not want!).
'-------------------------------------------------------------
'Extract meta data details from a folder containing .mp3 files
'18.2.2018 FNL
'-------------------------------------------------------------
Dim oFSO, oShell, oWshShell, oShellFolder
Dim sFolder, aCols, sTarget, oTarget, sTitle, sLine, bFirst, iCount
Prepare
ProcessFolders(sFolder)
oTarget.Close
MsgBox iCount & " files processed." & vbLf _
& "Results are stored on the desktop in the list ""Music Files.csv""", 64, sTitle
oWshShell.Run """" & sTarget & """", 1, False
'----------------------------------------
'Recursively process the nominated folder
'----------------------------------------
Sub ProcessFolders(sFldr)
ProcessOneFolder(sFldr) 'extract meta data from the .mp3 files in this folder
For Each oSubFolder In oFSO.GetFolder(sFldr).SubFolders
ProcessFolders(oSubFolder.Path) 'process all subfolders in this folder
Next
End Sub
'----------------------------------------------
'Process all .mp3 files in the nominated folder
'----------------------------------------------
Sub ProcessOneFolder(sFldr)
bStart = True
Set oMusicFolder = oFSO.GetFolder(sFldr)
For Each oFile In oMusicFolder.Files
If LCase(Right(oFile.Name, 4)) = ".mp3" Then
If bStart Then oWshShell.Popup "Processing """ & sFldr & """", 2, sTitle, 64
bStart = False
iCount = iCount + 1
Set oShellFolder = oShell.Namespace(sFldr)
If bFirst Then
bFirst = False
sLine = "File name" & vbTab
For Each iCol In aCols
extract iCol, oFile.Path, True
Next
oTarget.WriteLine sLine
End If
sLine = oFile.Path & vbTab
For Each iCol In aCols
Extract iCol, oFile.Name, False
Next
oTarget.WriteLine sLine
End If
Next
End Sub
'--------------------------------------------------------
'Extract the meta data column data for the specified file
'--------------------------------------------------------
Sub Extract(n, sItemName, bHeader)
sItem = Trim(oShellFolder.GetDetailsOf(oShellFolder.Parsename(sItemName), n))
If n = 28 Then
If bHeader _
Then sItem = sItem & " (kBits/s)" _
Else sItem = Mid(sItem, 2, Len(sItem) -5)
End If
sLine = sLine & sItem & vbTab
End Sub
'--------------------
'Prepare a few things
'--------------------
Sub Prepare
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Shell.Application")
Set oWshShell = CreateObject("WScript.Shell")
If wscript.Arguments.count = 0 _
Then Error "You must give the script the full name of your music folder!"
sFolder = oFSO.GetFolder(WScript.Arguments(0)).Path 'Include the full path if necessary
If Not oFSO.FolderExists(sFolder) Then Error "Cannot find the folder """ & sFolder & """."
sTitle = "MP3 File Analyzer"
sTarget = oWshShell.SpecialFolders("Desktop") & "\Music Files.csv"
On Error Resume Next
Set oTarget = oFSO.CreateTextFile(sTarget, True, True)
iErr = Err.Number
On Error Goto 0
If iErr <> 0 Then Error "The target file """ & sTarget & """ is in use!"
aCols = Split("1 3 27 28") 'size, date, length, bit rate
bFirst = True
iCount = 0
End Sub
'----------
'Error exit
'----------
Sub Error(sMsg)
MsgBox sMsg, 48, sTitle
WScript.Quit
End Sub