|
-
Mar 4th, 2002, 06:07 AM
#1
Thread Starter
Hyperactive Member
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
-
Mar 4th, 2002, 06:37 AM
#2
Re: MP3 Duplicates Searching program
This should increase the speed a bit
VB Code:
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)
Else
x = Len(String2)
End If
'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
If Mid$(String1, i, 1) = Mid$(String2, i, 1) Then y = y + 1
Next
CompareTXT = y / x * 100
End Function
-
Dec 17th, 2002, 06:35 AM
#3
Addicted Member
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
-
Dec 17th, 2002, 10:42 AM
#4
Thread Starter
Hyperactive Member
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
-
Dec 17th, 2002, 10:46 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|