Function DoFixFile(fname As String) As String
Dim char1, char2, char3, nfname As String
Dim pdone, paren As Boolean
Dim takeoff, maxlen As Long
x = 1
Do While x <= Len(fname)
char1 = Mid$(fname, x, 1)
If x < Len(fname) - 1 Then
char2 = Mid$(fname, x + 1, 1)
End If
If x < Len(fname) - 2 Then
char3 = Mid$(fname, x + 2, 1)
End If
'in case of track numbering, get rid of that shit,
'but only for the first three characters. after that, you're fucked.
If (x = 1 Or x = 2 Or x = 3) And (char1 = "0" Or char1 = "1" _
Or char1 = "2" Or char1 = "3" Or char1 = "4" Or char1 = "5" _
Or char1 = "6" Or char1 = "7" Or char1 = "8" Or char1 = "9") _
Then
'hypothetical: "xx_djname" => "djname"
If x = 1 And char3 = "_" Then
char1 = ""
x = x + 2
GoTo doloop
End If
If x = 1 And char3 = " " Then
char1 = ""
x = x + 2
GoTo doloop
End If
If x = 2 And char3 = "_" Then
char1 = ""
x = x + 2
GoTo doloop
End If
If x = 2 And char3 = " " Then
char1 = ""
x = x + 2
GoTo doloop
End If
If char1 = "4" And char2 = " " And LCase$(Mid$(fname, x + 2, 1)) = "s" Then
GoTo doloop
Else
If char2 = "-" Then
char1 = ""
x = x + 1
GoTo doloop
Else
char1 = ""
End If
End If
End If
If LCase$(char1) = "d" And LCase$(char2) = "j" Then
char1 = "DJ"
x = x + 1
GoTo doloop
End If
If char1 = "_" Then
If char2 = "_" Then
char3 = Mid$(fname, x + 2, 1)
char1 = " (" + UCase$(char3)
x = x + 2
paren = True
GoTo doloop
ElseIf char2 = "(" Then
char3 = Mid$(fname, x + 2, 1)
char1 = " (" + UCase$(char3)
x = x + 2
paren = True
GoTo doloop
Else
char2 = UCase$(char2)
char1 = " " + char2
x = x + 1
GoTo doloop
End If
End If
If char1 = " " Then
char2 = UCase$(char2)
char1 = " " + char2
x = x + 1
GoTo doloop
End If
If char1 <> " " And char1 <> "_" And char1 <> ")" And char2 = "-" And char3 <> "" Then
If char3 <> "(" Then
char1 = char1 + " - " + UCase$(char3)
x = x + 2
GoTo doloop
Else
char1 = char1 + " - "
x = x + 1
GoTo doloop
End If
End If
If char1 = ")" Then paren = False
doloop:
nfname = nfname + char1
x = x + 1
Loop
If txtCut.Text <> "" Then
On Error Resume Next
nfname = Mid$(nfname, 1, InStr(1, nfname, txtCut.Text) - 1) + ".mp3"
GoTo fuckingover
End If
If Len(nfname) > 30 Then maxlen = 20 Else maxlen = 14
pdone = False
If paren = True Then
x = 1
Do While x < maxlen
echo = Mid$(nfname, Len(nfname) - x, 1)
If echo = "-" Then
x = x + 2
nfname = Mid$(nfname, 1, Len(nfname) - x) + ").mp3"
pdone = True
Exit Do
End If
x = x + 1
Loop
If pdone = False Then nfname = Mid$(nfname$, 1, (Len(nfname) - 5)) + ").mp3"
ElseIf pdone = False Then
x = 1
Do While x < maxlen
echo = Mid$(nfname, Len(nfname) - x, 1)
If echo = "-" Then
If Mid$(nfname, Len(nfname) - (x + 1), 1) = " " Then takeoff = 2 Else takeoff = 1
x = x + takeoff
nfname = Mid$(nfname, 1, Len(nfname) - x) + ".mp3"
Exit Do
End If
x = x + 1
Loop
Else
x = 1
Do While x < 10
echo = Mid$(nfname, Len(nfname) - x, 1)
If echo = "-" Then
x = x + 2
nfname = Mid$(nfname, 1, Len(nfname) - x) + ".mp3"
Exit Do
End If
x = x + 1
Loop
End If
fuckingover:
char1 = Mid$(nfname, 1, 1)
nfname = UCase$(char1) + Mid$(nfname, 2)
DoFixFile = nfname
End Function