title
Products            Buy            Support Forum            Professional            About            Codec Central
 

VBCode to fix MP3 Files Missing Artist Names...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • McDougall

    VBCode to fix MP3 Files Missing Artist Names...

    Ahh... thought I'd throw this out.

    A friend of mine recently merged MP3 collections with me adding 100+ CD's to what I had. The problem is, he didn't have dB set up to put the Artist Name in the title..... which can suck if you mix them up.

    From Him:
    15 - Stay.mp3

    Should Be:
    15 Belly - Stay.mp3

    Instead of doing a hand job on the 100 albums (maybe 1500+ songs?) I wrote this out really quick in VB6 to get the Artist Name from the folder:
    ....\Belly - Star\
    ....\Rush - Exit Stage Left\

    ("Rush" and "Belly" are used as the artist names from the folders above)


    Then add in that artist name to all of the songs on the folder.

    .....\Belly - Star\15 - Stay.mp3

    becomes

    .....\Belly - Star\15 Belly - Stay.mp3

    If you make an EXE and stick it in a folder or drive, it will run through every folder on the drive, or in the folder it's in.

    Blah Blah...

    Code:
    Private Sub Command1_Click()
    
    Dim TempA As String
    Dim StartLocation As String
    Dim FileName As String
    Dim DirName As String
    Dim FolderList() As String
    Dim FolderCount As Integer
    Dim SongList() As String
    Dim SongCount As Integer
    Dim ArtistName As String
    Dim ArtistNameLength As Integer
    Dim ArtistNameStart As Integer
    
    StartLocation = App.Path
    TempA = StartLocation
    FolderCount = 0
    SoungCount = 0
    
    If Right(TempA, 1) <> "\" Then TempA = TempA & "\"
    DirName = Dir(TempA, vbDirectory)
        Do While Len(DirName) > 0
            If (DirName <> ".") And (DirName <> "..") Then
                If GetAttr(TempA & DirName) And vbDirectory Then
                    FolderCount = FolderCount + 1
                    ReDim Preserve FolderList(FolderCount)
                    FolderList(FolderCount) = DirName
                End If
            End If
            DirName = Dir()
        Loop
    
    For Y = 1 To FolderCount
        For Z = 1 To Len(FolderList(Y))
            TempA = Mid(FolderList(Y), Z, 1)
            If TempA = "-" Then
                    If Mid(FolderList(Y), Z - 1, 1) <> " " Then
                        ArtistName = Left$(FolderList(Y), Z - 1)
                        Exit For
                    Else
                        ArtistName = Left$(FolderList(Y), Z - 2)
                    Exit For
                End If
            End If
        Next Z
        
            ArtistNameLength = Len(ArtistName)
            
            TempA = StartLocation & "\" & FolderList(Y) & "\"
            ChDir TempA
            
            FileName = Dir(TempA, vbNormal Or vbReadOnly)
    
            SongCont = 0
            ReDim SongList(SongCount)
            
            While Len(FileName) <> 0
                SongCount = SongCount + 1
                ReDim Preserve SongList(SongCount)
                SongList(SongCount) = FileName
                FileName = Dir()
            Wend
        For X = 1 To SongCount
            For Z = 1 To Len(SongList(X))
                If Mid$(SongList(X), Z, 1) = " " Then
                    ArtistNameStart = Z + 1
                    Exit For
                End If
            Next Z
            If ArtistName = Mid$(SongList(1), ArtistNameStart, ArtistNameLength) Then GoTo NEXTSONG
        
                For Z = 1 To Len(SongList(X))
                    If Mid$(SongList(X), Z, 1) = " " Then
                        TempA = Mid$(SongList(X), 1, Z)
                        TempA = TempA & ArtistName
                        TempA = TempA & " "
                        TempA = TempA & Mid$(SongList(X), Z + 1, Len(SongList(X)) - Z)
                        Name SongList(X) As TempA
                        Exit For
                    End If
                Next Z
    NEXTSONG:
        Next X
    Next Y
    End Sub
Working...

]]>