As always, the installer can be downloaded from my website.
Code: Select all
'
' MediaMonkey Script
'
' NAME: MoveFiles 1.2
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 10/01/2010
'
' INSTALL: Copy to Scripts\Auto directory
'
' FIXES: Fixed buddy files not being renamed when necessary
'
Option Explicit
Dim Types : Types = Array("asd")
Dim CopyOver : CopyOver = True
Sub OnStartUp()
Call Script.RegisterEvent(SDB,"OnBeforeTracksMove","MoveFiles")
End Sub
Sub MoveFiles(tracks,paths,move)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim i : i = 0
Dim j : j = 0
'loop through tracks being moved
For i = 0 To tracks.Count-1
Dim itm : Set itm = tracks.Item(i)
Dim pos : pos = InStrRev(itm.Path,".")
Dim oldf : oldf = Left(itm.Path,pos-1)
Dim olde : olde = Mid(itm.Path,pos)
'loop through extensions to check
For j = 0 To UBound(Types)
pos = InStrRev(paths.Item(i),".")
Dim newf : newf = Left(paths.Item(i),pos-1)
Dim newe : newe = ""
Dim tmpe : tmpe = "."&Types(j)
'check if either buddy file exists
If fso.FileExists(oldf&tmpe) Then
newe = tmpe
Else
If fso.FileExists(oldf&olde&tmpe) Then
newe = olde&tmpe
End If
End If
'move or copy buddy file
If Not (newe = "") Then
Dim sour : sour = oldf&newe
Dim dest : dest = newf&newe
If Not (sour = dest) Then
Call GeneratePath(Left(dest,InStrRev(dest,"\")))
If move Then
Call fso.MoveFile(sour,dest)
Else
Call fso.CopyFile(sour,dest,CopyOver)
End If
End If
End If
Next
Next
End Sub
Function GeneratePath(pFolderPath)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
GeneratePath = False
If Not fso.FolderExists(pFolderPath) Then
If GeneratePath(fso.GetParentFolderName(pFolderPath)) Then
GeneratePath = True
Call fso.CreateFolder(pFolderPath)
End If
Else
GeneratePath = True
End If
End Function