1' lame.vbs WindowsScript wrapper v0.5, 06/15/2001 2' $id$ 3' 4' *Purpose* 5' Use this WindowsScript to encode WAVs using drag&drop: 6' 0. make sure you have windows script host v5.1 on your system 7' (enter 'cscript' in a DOS-Box and compare version number) 8' 1. adjust the path settings below to fit your needs 9' 2a. put this file somewhere on the desktop 10' 3a. drag one or more wav-files on the icon and watch them being lamed. 11' 12' 2b. start->execute, enter "sendto", drag the script or a link to it in 13' sendto window (adjust names and icon as you like) 14' 3b. select wave-file(s) and send it via the send-to menu to LAME! 15' 16' You may wish to create copies of this file with different options set. 17' 18' If you would like a GUI: try to enable the HTML UI (see below) 19' 20' Ralf Kempkens, ralf.kempkens@epost.de 21' 22' 23' *History* 24' V0.5 * lame.vbs will automatically decode if the file has a .mp3 extension 25' * now explicitly refuses to accept folders 26' V0.4 * creates single .mp3 extensions, now ID3 options in HTML interface 27' V0.3 * fixed bug that prevented lame.exe to be located in a path that 28' contained a space 29' * experimental HTML UI support (disabled by default) 30' V0.2 added multiple file support 31' V0.1 initial release 32 33' *** change path to your needs *** 34 path = "D:\Audio\Lame\Lame386\" '!!! must end with a backslash !!! 35 lame = "lame.exe" 36 37' *** change default options to your needs *** 38 opts = "--preset hifi" 39 40' *** HTML GUI (experimental) *** 41 useGUI = False 42' it set to True, opens file lameGUI.html residing in the same path as lame.exe 43' to choose options. Please look at the example HTML-file for further information. 44 45' no changes needed below this line 46' ########################################################################## 47Dim wsh, args, infile, fs 48title="LAME Script" 49 50' get input files 51Set wsh = WScript.CreateObject("WScript.Shell") 52Set args = WScript.Arguments 53If args.Count = 0 Then 54 MsgBox "LAME mp3 encoder/decoder frontend script." & vbCR & _ 55 "Please use drag & drop to specify input files.", vbInformation, title 56 WScript.Quit 57End If 58 59' check path 60Set fso = CreateObject("Scripting.FileSystemObject") 61If Not fso.FileExists(path & lame) Then 62 MsgBox "Could not find LAME!" & vbCR & "(looked for '" & path & lame & "')", vbCritical, title 63 WScript.Quit 64End If 65 66' start GUI 67if useGUI Then 68 set ie=WScript.CreateObject("InternetExplorer.Application", "ie_") 69 ie.navigate(path & "lameGUI.html") 70 do 71 WScript.Sleep 100 72 loop until ie.ReadyState=4 'wait for GUI 73 74 ie.Width=640 75 ie.Height=600 76 ie.Toolbar=false 77 ie.Statusbar=false 78 ie.visible=true 79 80 'link to GUI 81 set document=ie.document 82 document.forms.lameform.okbutton.onClick=GetRef("okbutton") 83 84 'wait for user pressing ok... 85 do 86 WScript.Sleep 300 87 loop until process 88end if 89 90'process files 91For i = 0 To args.Count-1 92 infile = args(i) 93 ' check input file 94 If fso.FolderExists(infile) Then 95 MsgBox "'" & infile & "' is a folder!" & vbCR & _ 96 title & " only handles proper files.", vbInformation, title 97 Else 98 If Not fso.FileExists(infile) Then 99 MsgBox "Error opening input-file" & vbCR & "'" & infile & "'", vbCritical , title 100 Else 101 ' run lame 102 If(LCase(getExtension(infile))="mp3") Then 'decode 103 ret = wsh.Run(Chr(34) & path & lame & CHR(34) & " --decode " & _ 104 Chr(34) & infile & Chr(34) & Chr(32) & Chr(34) & _ 105 getBasename(infile) & ".wav" & Chr(34), 1, True) 106 Else ' encode 107 ret = wsh.Run(Chr(34) & path & lame & CHR(34) & Chr(32) & opts & Chr(32) & _ 108 Chr(34) & infile & Chr(34) & Chr(32) & Chr(34) & _ 109 getBasename(infile) & ".mp3" & Chr(34), 1, True) 110 End If 111 ' diagnostics 112 Select Case ret 113 Case (0) 'okeydokey 114 Case (-1) 115 MsgBox "LAME aborted by user!", vbExclamation, title 116 Case (1) 117 MsgBox "Error returned by LAME!" & vbCR & "(Check LAME options and input file formats.)" & vbCR & "Used Options: " & opts, vbCritical, title 118 Case Else 119 MsgBox "Received unknown LAME return-code: " & ret, vbCritical, title 120 End Select 121 End If 122 End If 123Next 124 125WScript.Quit 126' ******************************************************************* 127' utility functions 128 129Function getBasename(filespec) 130 Dim fso 131 Set fso = CreateObject("Scripting.FileSystemObject") 132 Set f = fso.GetFile(filespec) 133 134 getBasename = f.ParentFolder & "\" & fso.GetBaseName(filespec) 135End Function 136 137Function getExtension(filespec) 138 Dim fso 139 Set fso = CreateObject("Scripting.FileSystemObject") 140 Set f = fso.GetFile(filespec) 141 142 getExtension = fso.GetExtensionName(filespec) 143End Function 144 145' ******************************************************************* 146' manage link to IE HTML-interface 147 148sub okbutton 149 'process inputs 150 opts=document.all.lameoptions.Value 151 ie.Quit 152 MsgBox "LAME options:" & vbCR & opts, vbInformation, title 153end sub 154 155sub ie_onQuit 156 process=True 157end sub 158'eof 159