How to copy a track from a script?

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

How to copy a track from a script?

Post by Begges »

Hi,

how is it possible to copy selected tracks to another folder,drive etc.?
I am not talking about the auto organisation but about something, that i can use from within a script.

Thanks for your help

Begges
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Yes.

You can get the path to the song file from the SDBSongData's property Path.
Like (getting the path to the currently playing song):

Code: Select all

Dim FileName : FileName = SDB.Player.CurrentSong.Path
Once you know the file name (path), you can do what you want using the "FileSystem Object (FSO)" (move, delete, copy, rename, ...).
Here's the FSO:

Code: Select all

Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Then you can do e.g. (copy song to temporary location):

Code: Select all

FSO.CopyFile(FileName, "C:\TempSong.dat", true)
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Here's a little script example. Adds a copy icon to the standard toolbar and when you hit it the selected files get copied to the folder you choose in the dialog.

Not much error controls and stuff in this one, but may get you going.

Code: Select all

'----------------------------------------------------------------------
'\Program Files\MediaMonkey\Scripts\Auto\CopyFiles.vbs
' Version: 0.95
' Date: 5 September 2006
' By DiddeLeeDoo
'----------------------------------------------------------------------
Sub OnStartup
Set CFT=SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard, 0, 0)
    CFT.Caption="Copy Files To"
    CFT.IconIndex=9
    CFT.UseScript=Script.ScriptPath
    CFT.OnClickFunc="CopyFiles"
End Sub

Sub CopyFiles(o)
Set FSO=CreateObject("Scripting.FileSystemObject")
Set SHL=CreateObject("Shell.Application")
Set dbT=SDB.CurrentSongList
Set FLD=SHL.BrowseForFolder(0,"Destination:",0,"") 
 If Not FLD Is Nothing Then
    For i = 0 To dbT.Count-1
        Set Sng=dbT.Item(i)
        CFr=Sng.Path
        CTo=FLD.Self.Path & "\" & Right(CFr,Len(CFr)-InStrRev(CFr,"\"))
        FSO.CopyFile CFr, CTo
    Next
 End If
End Sub
Added, I pasted in a 'test code'..... put the right one in just now..
Image
Begges
Posts: 20
Joined: Fri Apr 28, 2006 3:52 pm
Location: Germany

THANKS!!

Post by Begges »

Thanks a lot for your help..........
at the end i am trying to get a "replace double tracks with empty mp3file same tags and a link that links to the now not double track"-script.
Sounds strange and i am also not sure if anyone will need it (except of me with my small harddrive......)

Begges
Post Reply