Results 1 to 5 of 5

Thread: MP3 Duplicates Searching program

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    MP3 Duplicates Searching program

    Hello,

    I have very difficult question (For me ;])

    I'm making program witch would find duplicates in listview, but it wouldn't match 100%. For instance "ABCDE" and "ABCDF" would return 80%. It would be very useful for making program witch searches for duplicates mp3 songs (Almost same filenames, but not 100% match)

    I have done it, but my code is very slow. To search for duplicates in listview with 2500 items would take about 40 hours. How to optimize this code? (Earlier I used function .FindItem, it is very fast, but this search would found items, witch matches 100%)




    Listfiles1 = Listview (with filenames)
    Duplicates = Listview (duplicates items)

    My Code:
    Code:
    Private Sub FNDDPLBYNAME()
    Dim x0, x1
    Dim File0 As String, File1 As String
    Dim ListViewItemX As ListItem
    
    
    
    For x0 = 1 To ListFiles.ListItems.Count
    File0 = Trim$(ListFiles.ListItems.Item(x0).Text)
    File0 = Left$(File0, Len(File0) - 4)
    
    For x1 = x0 + 1 To ListFiles.ListItems.Count
    File1 = Trim$(ListFiles.ListItems.Item(x1).Text)
    File1 = Left$(File1, Len(File1) - 4)
    
    DoEvents
    Debug.Print x0
    If CompareTXT(File0, File1) >= 80 Then ' 80%, or other number to match songs filenames
    
    Duplicates.ListItems.Add , , ListFiles.ListItems.Item(x0).Text
    Duplicates.ListItems.Add , , ListFiles.ListItems.Item(x1).Text
    
    End If
    Next x1
    Next x0
    
    End Sub
    
    
    Public Function CompareTXT(String1 As String, String2 As String) As Single
        Dim i, y, x As Integer
        Dim a, b As String
        String1 = UCase$(String1) 'take this out If you
        String2 = UCase$(String2) 'want it To be case
        'sensitive
        If String1 = String2 Then CompareTXT = 1: Exit Function
        'if the strings are
        'the same, don't
        'bother to waste time
        'and space on working
        'them out :).
        If Len(String1) > Len(String2) Then x = Len(String1)
        If Len(String2) > Len(String1) Then x = Len(String2)
        If Len(String1) = Len(String2) Then x = Len(String1)
        'find out the length
        'of the longest string
    
    
        For i = 1 To x
        DoEvents
            a = Mid$(String1, i, 1) 'get 1 character from
            b = Mid$(String2, i, 1) 'each string and compare
            If a = b Then y = y + 1 'the characters
        Next
        CompareTXT = y / x * 100
    End Function

    Regards,
    Norkis

  2. #2
    Si_the_geek
    Guest

    Re: MP3 Duplicates Searching program

    This should increase the speed a bit
    VB Code:
    1. Public Function CompareTXT(String1 As String, String2 As String) As Single
    2.     Dim i, y, x As Integer
    3.     Dim a, b As String
    4.     String1 = UCase$(String1) 'take this out If you
    5.     String2 = UCase$(String2) 'want it To be case
    6.     'sensitive
    7.     If String1 = String2 Then CompareTXT = 1: Exit Function
    8.     'if the strings are
    9.     'the same, don't
    10.     'bother to waste time
    11.     'and space on working
    12.     'them out :).
    13.    
    14.     If Len(String1) => Len(String2) Then
    15.          x = Len(String1)
    16.     Else
    17.          x = Len(String2)
    18.     End If
    19.     'If Len(String2) > Len(String1) Then x = Len(String2)
    20.     'If Len(String1) = Len(String2) Then x = Len(String1)
    21.     'find out the length
    22.     'of the longest string
    23.  
    24.  
    25.     For i = 1 To x
    26.     'DoEvents
    27.         'a = Mid$(String1, i, 1) 'get 1 character from
    28.         'b = Mid$(String2, i, 1) 'each string and compare
    29.         'If a = b Then y = y + 1 'the characters
    30.         If Mid$(String1, i, 1) = Mid$(String2, i, 1) Then y = y + 1
    31.     Next
    32.     CompareTXT = y / x * 100
    33. End Function

  3. #3
    Addicted Member Jakys's Avatar
    Join Date
    Dec 1999
    Location
    Norway
    Posts
    180
    Does this work fine? What if one file is called:
    "this is a song.mp3" and the other one
    "02 - this_is_a_song.mp3"

    that would mean that with this code it's 0% similar?

    Im making the same program, just need some help on where to start
    MSN: [email protected]

    "Enhetssirkelen løser alle problemer" - ÅJT

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309
    This code works and if you improve it a little bit it would work fine.

    At this moment I cant try your example, but I think code wouldn't return 0%. It would be 20%-30% propably.

    Jakys, try my aplication, witch does it, www.mzk-soft.com (Duplicates Killer 1.0.6).

    If you have good ideas and expierence making soft, you may join me making this program.

    If so email me: norcis @ mzk . lt

    Regards

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    3 things to examine would also be file length.. scan all the MP3's for size... because if you have 2 mp3s that are both the same amount of bytes... then chances are they are the same... but not always..


    so 3 methods you might want to use are

    scanning file names
    scanning file sizes
    scanning ID3 tags

    combining all 3 would make an even more efficient scanner... but it would be more complex to program...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width