Music Tag Editor

danno_mbk

Board Regular
Joined
Sep 6, 2004
Messages
102
Hi just putting the feelers out here,

does anyone know if there is any code out there that enables me, you anyone... to pull down a list of music from a specfied drive, (with the TAG info , title, artist, track num, etc..) edit it if need be and save the changes ?

I have been manaully changing each track on my Zen Vision M so the tracks play in order and it takes ages ! (and I am a lazy sod!)

I managed to find some code Written by Andrew Fergus 10 September 2007, that lists most of the tag info (except track no) in the forums but no editor, any ideas anyone ?
I am working though it trying to add track number at the moment being a novice it could take a while but I am having a go :)

Andrews' code ...

'Notes:
'1) you will need to set a reference to 'Microsoft Scripting Runtime' under VBE menu option Tools > References
'2) set the name of the worksheet where you want the results stored with the constant 'MyOutputSheet'
'3) set the name of the drive/directory you want to search with the constant 'MyStartFolder'
'4) copy/paste the following code into the 'This Workbook' module of your spreadsheet:


Option Explicit
'____________________________________________________________
'
'Written by Andrew Fergus 10 September 2007
'Set a reference to 'Microsoft Scripting Runtime' under VBE
' menu option Tools > References
'____________________________________________________________

Private Type TagInformation 'assumes ID3 format
Tag As String * 3
SongName As String * 30
Artist As String * 30
Album As String * 30
Year As String * 4
Track As String * 3
Comment As String * 30
Genre As String * 1

End Type

Public RowCount As Long
Public ColumnCount As Long

'SET THE DRIVE / FOLDER TO SEARCH HERE
Const MyStartFolder As String = "c:\My media"
'SET THE WORKSHEET NAME TO HOLD THE RESULTS HERE
Const MyOutputSheet As String = "Sheet1"

Public Sub GetMyList()
'This is the macro you run from menu option Tools > Macros

RowCount = 1
ColumnCount = 1

Application.Cursor = xlWait
RetrieveSongs (MyStartFolder)

Application.Cursor = xlDefault
MsgBox "Finished compiling song list.", vbInformation, "Done!"

End Sub


Sub RetrieveSongs(Location As String)

On Error GoTo ErrorHandler

Dim fso As New FileSystemObject
Dim fsoFile As File
Dim fsoFolder As Folder
Dim FileTag As TagInformation

'Search this folder for files
For Each fsoFile In fso.GetFolder(Location).Files
If LCase(Right$(fsoFile.Name, 3)) = "mp3" Or _
LCase(Right$(fsoFile.Name, 3)) = "wma" Then
Open fsoFile.path For Binary As #1
With FileTag
Get #1, FileLen(fsoFile.path) - 127, .Tag
If UCase(.Tag) = "TAG" Then
Get #1, , .SongName
Get #1, , .Artist
Get #1, , .Album
Get #1, , .Year

Call WriteSong(fsoFile.Name, _
fsoFile.parentfolder, _
RTrim(.SongName), _
RTrim(.Artist), _
RTrim(.Album), _
RTrim(.Year))

Else
Call WriteSong(fsoFile.Name, _
fsoFile.parentfolder)
End If
End With
Close #1
End If
Next

'Search this folder for more folders
For Each fsoFolder In fso.GetFolder(Location).SubFolders
Call RetrieveSongs(fsoFolder.path)
Next

Exit_Here:
Set fsoFile = Nothing
Set fsoFolder = Nothing
Set fso = Nothing
Exit Sub

ErrorHandler:
Application.Cursor = xlDefault
Close #1
MsgBox "There was an unexpected error." & vbCrLf & _
Err.Description, vbCritical, "Error# " & Err.Number
GoTo Exit_Here

End Sub

Sub WriteSong(filename As String, _
filefolder As String, _
Optional MySongName As String, _
Optional MySongArtist As String, _
Optional MySongAlbum As String, _
Optional MySongYear As String)

Dim tmpString As String

If RowCount = 65536 Then
RowCount = 2
ColumnCount = ColumnCount + 11
Else
RowCount = RowCount + 1
End If

With Sheets(MyOutputSheet)
.Cells(RowCount, ColumnCount).Value = filename 'file name
.Cells(RowCount, ColumnCount + 1).Value = filefolder 'file location
.Cells(RowCount, ColumnCount + 2).Value = "'" & MySongName
.Cells(RowCount, ColumnCount + 3).Value = "'" & MySongArtist
.Cells(RowCount, ColumnCount + 4).Value = "'" & MySongAlbum
.Cells(RowCount, ColumnCount + 5).Value = "'" & MySongYear
tmpString = "'" & LCase(Right$(filename, 3))
.Cells(RowCount, ColumnCount + 6).Value = tmpString 'type
If InStr(1, filefolder, "\", vbTextCompare) > 1 Then
tmpString = "'" & Right$(filefolder, InStr(1, StrReverse(filefolder), "\", vbTextCompare) - 1)
End If
.Cells(RowCount, ColumnCount + 7).Value = tmpString 'folder
If InStr(1 + InStr(1, filefolder, "\", vbTextCompare), filefolder, "\", vbTextCompare) > 1 Then
tmpString = Left$(filefolder, Len(filefolder) - InStr(1, StrReverse(filefolder), "\", vbTextCompare))
tmpString = "'" & Right$(tmpString, InStr(1, StrReverse(tmpString), "\", vbTextCompare) - 1)
End If
.Cells(RowCount, ColumnCount + 8).Value = tmpString 'parent folder
End With

End Sub


cheers danno
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Seems you might be trying to reinvent the wheel here.

There are loads of different software programs which allow batch renaming of ID3 tags on mp3s.

Google search 'ID3 tag editor' - there are some decent free ones and some shareware ones you can use the trial period of to acheive your goal.
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,653
Members
449,245
Latest member
PatrickL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top