Code: Select all
'
' MediaMonkey Script
'
' NAME: ShortcutCreator 1.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 10/03/2006
'
' Thanks for Steegy for the SkinnedInputBox
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' [ShortcutCreator]
' FileName=ShortcutCreator.vbs
' ProcName=ShortcutCreator
' Order=33
' DisplayName=Shortcut Creator
' Description=Shortcut Creator
' Language=VBScript
' ScriptType=0
'
'
Option Explicit
Dim Progress
Sub ShortcutCreator
Dim list,res
Set list = SDB.CurrentSongList
If list.Count = 0 Then
res = SDB.MessageBox("There are no selected tracks.",mtInformation,Array(mbOk))
Set list = Nothing
Exit Sub
End If
Dim path
path = SDB.IniFile.StringValue("Scripts","LastShortcutPath")
path = SkinnedInputBox("Please enter full output path:","ShortcutCreator",path,"ShortcutCreator")
If path = "" Then
res = SDB.MessageBox("No output directory selected.",mtInformation,Array(mbOk))
Set list = Nothing
Exit Sub
End If
If Right(path,1) = "\" Then
path = Left(path,Len(path)-1)
End If
Set Progress = SDB.Progress
Progress.MaxValue = list.Count
progtext("Initialising script...")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FolderExists(path) Then
fso.CreateFolder(path)
End If
SDB.IniFile.StringValue("Scripts","LastShortcutPath") = path
Dim i,itm,wso,loc,lnk
Set wso = CreateObject("WScript.Shell")
For i = 0 To list.Count-1
Set itm = list.Item(i)
Progress.Value = i+1
progtext("Creating shortcut for track "&(i+1)&" of "&list.Count&"...")
loc = path&"\"&fso.GetBaseName(itm.Path)&".lnk"
Set lnk = wso.CreateShortcut(loc)
lnk.TargetPath = itm.Path
lnk.Save
Set lnk = Nothing
Set itm = Nothing
If Progress.Terminate Then Exit For
Next
Set Progress = Nothing
Set fso = Nothing
Set wso = Nothing
Set list = Nothing
End Sub
Function progtext(txt)
progtext = "Shortcut Creator - "&txt
Progress.Text = progtext
SDB.ProcessMessages
End Function
Function SkinnedInputBox(Text, Caption, Input, PositionName)
Dim Form, Label, Edt, btnOk, btnCancel, modalResult
' Create the window to be shown
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 360, 130
Form.BorderStyle = 2 ' Resizable
Form.FormPosition = 4 ' Screen Center
Form.SavePositionName = PositionName
Form.Caption = Caption
' Create a button that closes the window
Set Label = SDB.UI.NewLabel(Form)
Label.Caption = Text
Label.Common.Left = 5
Label.Common.Top = 10
Set Edt = SDB.UI.NewEdit(Form)
Edt.Common.Left = Label.Common.Left
Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5
Edt.Common.Width = Form.Common.Width - 20
Edt.Common.ControlName = "Edit1"
Edt.Common.Anchors = 1+2+4 'Left+Top+Right
Edt.Text = Input
' Create a button that closes the window
Set BtnOk = SDB.UI.NewButton(Form)
BtnOk.Caption = "&OK"
BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10
BtnOk.Common.Hint = "OK"
BtnOk.Common.Anchors = 4 ' Right
BtnOk.UseScript = Script.ScriptPath
BtnOk.Default = True
BtnOk.ModalResult = 1
Set BtnCancel = SDB.UI.NewButton(Form)
BtnCancel.Caption = "&Cancel"
BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15
BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10
BtnCancel.Common.Top = BtnOK.Common.Top
BtnCancel.Common.Hint = "Cancel"
BtnCancel.Common.Anchors = 4 ' Right
BtnCancel.UseScript = Script.ScriptPath
BtnCancel.Cancel = True
BtnCancel.ModalResult = 2
If Form.showModal = 1 Then
SkinnedInputBox = Edt.Text
Else
SkinnedInputBox = ""
End If
End Function