How to copy a track from a script?

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: How to copy a track from a script?

THANKS!!

by Begges » Wed Sep 06, 2006 2:41 pm

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

by DiddeLeeDoo » Tue Sep 05, 2006 9:45 pm

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..

by Steegy » Tue Sep 05, 2006 5:44 pm

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

How to copy a track from a script?

by Begges » Tue Sep 05, 2006 3:33 pm

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

Top