VBS Script To Enumerate MP3 Files In A Specified Media Folder And Send To Excel

 

This is a VBS script that I wrote to allow me enumerate the MP3 files in my Windows Media Player C:\Documents and Settings\Don\My Documents\My Music folder.

 

The script will send the following information to an excel spreadsheet: Track, Title, Artist, Album, Size and Length.

 

VBS Script:

 

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.BrowseForFolder (0, "Select Media Folder:", (0))

If objFolder Is Nothing Then

Wscript.Quit

Else

Set objFolderItem = objFolder.Self

objPath = objFolderItem.Path

End If

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Track"

objExcel.Cells(1, 2).Value = "Title"

objExcel.Cells(1, 3).Value = "Artist"

objExcel.Cells(1, 4).Value = "Album"

objExcel.Cells(1, 5).Value = "Size"

objExcel.Cells(1, 6).Value = "Length"

 

Set objShell = CreateObject ("Shell.Application")

For Each strFileName in objFolder.Items

objExcel.Cells(intRow, 1).Value = objFolder.GetDetailsOf(strFileName, 20) 'Track

objExcel.Cells(intRow, 2).Value = objFolder.GetDetailsOf(strFileName, 0) 'Title

objExcel.Cells(intRow, 3).Value = objFolder.GetDetailsOf(strFileName, 10) 'Artist

objExcel.Cells(intRow, 4).Value = objFolder.GetDetailsOf(strFileName, 18) 'Ablum

objExcel.Cells(intRow, 5).Value = objFolder.GetDetailsOf(strFileName, 8) 'Size

objExcel.Cells(intRow, 6).Value = objFolder.GetDetailsOf(strFileName, 22) 'Length

intRow = intRow + 1

Next

 

objExcel.Range("A1:F1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

 

 

Published Sunday, July 27, 2008 8:02 AM by dhite
Filed under:

Comments

No Comments