Shortcut Creator 1.0 [MM2+3]

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

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Shortcut Creator 1.0 [MM2+3]

Post by trixmoto »

This script, as requested here, creates shortcuts to the selected tracks in the entered directory.

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
Last edited by trixmoto on Mon Nov 12, 2007 11:04 am, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Skyhawker

Post by Skyhawker »

Thanks for your quick response to that...credit to the community and all that :)

I haven't got it to work yet though.
it's in scripts folder as "ShortcutCreator.vbs"
Scripts.ini has been added to ..(what am I meant to change order to? I put 6?)

but I get error: File unavailable, or may not have permission to acces it...I can't think of what to do...I'll come back to it tomorrow when I'm awake..

-Skyhawker
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

The order doesn't really matter.

Personally I would suggest downloading the installer for this script from my website. Don't forget you'll need to restart MM before the script is usable!
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

An MM3 installation package is now available from my website for this script. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Erwin Hanzl
Posts: 1190
Joined: Tue Jun 13, 2017 8:47 am
Location: Vienna

Re: Shortcut Creator 1.0 [MM2+3]

Post by Erwin Hanzl »

Hello Rik,
I have optimized your script (a mail with the .vbs is on the way)

The destination folder can be easily selected:
Image


Copy the code below and save the file named "ShortcutCreator.vbs" to the folder: %appdata%\Mediamonkey\Scripts

Code: Select all

''
' MediaMonkey Script
'
' NAME: ShortcutCreator 1.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE :  10/03/2006 
' UPDATE: 25.07.2019 - Autor Erwin Hanzl - With permission from Rik Lewis

' 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.SelectedSongList                                                             'by ERWIN HANZL 25.07.2019  OLD: SDB.CurrentSongList
  If list.Count = 0 Then
    res = SDB.MessageBox("There are no selected tracks.",mtInformation,Array(mbOk))
    Set list = Nothing
    Exit Sub
  else                                                                                                                  'by ERWIN HANZL 25.07.2019
    res = SDB.MessageBox(list.count &"   joins are created - do you really want that?",mtInformation,Array(mbOK,mbNO))  'by ERWIN HANZL 25.07.2019
    if res<>1 then                                                                                                      'by ERWIN HANZL 25.07.2019
        Set list = Nothing                                                                                              'by ERWIN HANZL 25.07.2019
	exit Sub                                                                                                        'by ERWIN HANZL 25.07.2019
    end if                                                                                                              'by ERWIN HANZL 25.07.2019
  End If 

'-------------------------------------------------- START: from ExportM3Us by ERWIN HANZL 25.07.2019
  ' Open inifile and get last used directory 
  Dim path
  Dim iniF
  Set iniF = SDB.IniFile

  ' Let user select the output path
  path = SDB.IniFile.StringValue("Scripts","LastShortcutPath")

  path = SDB.SelectFolder( path, SDB.Localize( "Select where to export all link-files."))

  If path="" Then
    Exit Sub
  End If

  If Right( path, 1)<>"\" Then
    path = path & "\"
  End If

  ' Write selected directory to the ini file
  iniF.StringValue( "Scripts", "LastShortcutPath") = path
  Set iniF = Nothing

'-------------------------------------------------- END: from ExportM3Us by ERWIN HANZL 25.07.2019

  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
Then open with windows-editor the file "Scripts.ini" in the folder %appdata%\Mediamonkey\Scripts and copy the following code to the end.

[ShortcutCreator]
FileName=ShortcutCreator.vbs
ProcName=ShortcutCreator
Order=33
DisplayName=Shortcut Creator
Description=Shortcut Creator
Language=VBScript
ScriptType=0
MMW 4.1.31.1919 Gold-Standardinstallation
Post Reply