1159b3361Sopenharmony_ci' lame.vbs WindowsScript wrapper v0.5, 06/15/2001 2159b3361Sopenharmony_ci' $id$ 3159b3361Sopenharmony_ci' 4159b3361Sopenharmony_ci' *Purpose* 5159b3361Sopenharmony_ci' Use this WindowsScript to encode WAVs using drag&drop: 6159b3361Sopenharmony_ci' 0. make sure you have windows script host v5.1 on your system 7159b3361Sopenharmony_ci' (enter 'cscript' in a DOS-Box and compare version number) 8159b3361Sopenharmony_ci' 1. adjust the path settings below to fit your needs 9159b3361Sopenharmony_ci' 2a. put this file somewhere on the desktop 10159b3361Sopenharmony_ci' 3a. drag one or more wav-files on the icon and watch them being lamed. 11159b3361Sopenharmony_ci' 12159b3361Sopenharmony_ci' 2b. start->execute, enter "sendto", drag the script or a link to it in 13159b3361Sopenharmony_ci' sendto window (adjust names and icon as you like) 14159b3361Sopenharmony_ci' 3b. select wave-file(s) and send it via the send-to menu to LAME! 15159b3361Sopenharmony_ci' 16159b3361Sopenharmony_ci' You may wish to create copies of this file with different options set. 17159b3361Sopenharmony_ci' 18159b3361Sopenharmony_ci' If you would like a GUI: try to enable the HTML UI (see below) 19159b3361Sopenharmony_ci' 20159b3361Sopenharmony_ci' Ralf Kempkens, ralf.kempkens@epost.de 21159b3361Sopenharmony_ci' 22159b3361Sopenharmony_ci' 23159b3361Sopenharmony_ci' *History* 24159b3361Sopenharmony_ci' V0.5 * lame.vbs will automatically decode if the file has a .mp3 extension 25159b3361Sopenharmony_ci' * now explicitly refuses to accept folders 26159b3361Sopenharmony_ci' V0.4 * creates single .mp3 extensions, now ID3 options in HTML interface 27159b3361Sopenharmony_ci' V0.3 * fixed bug that prevented lame.exe to be located in a path that 28159b3361Sopenharmony_ci' contained a space 29159b3361Sopenharmony_ci' * experimental HTML UI support (disabled by default) 30159b3361Sopenharmony_ci' V0.2 added multiple file support 31159b3361Sopenharmony_ci' V0.1 initial release 32159b3361Sopenharmony_ci 33159b3361Sopenharmony_ci' *** change path to your needs *** 34159b3361Sopenharmony_ci path = "D:\Audio\Lame\Lame386\" '!!! must end with a backslash !!! 35159b3361Sopenharmony_ci lame = "lame.exe" 36159b3361Sopenharmony_ci 37159b3361Sopenharmony_ci' *** change default options to your needs *** 38159b3361Sopenharmony_ci opts = "--preset hifi" 39159b3361Sopenharmony_ci 40159b3361Sopenharmony_ci' *** HTML GUI (experimental) *** 41159b3361Sopenharmony_ci useGUI = False 42159b3361Sopenharmony_ci' it set to True, opens file lameGUI.html residing in the same path as lame.exe 43159b3361Sopenharmony_ci' to choose options. Please look at the example HTML-file for further information. 44159b3361Sopenharmony_ci 45159b3361Sopenharmony_ci' no changes needed below this line 46159b3361Sopenharmony_ci' ########################################################################## 47159b3361Sopenharmony_ciDim wsh, args, infile, fs 48159b3361Sopenharmony_cititle="LAME Script" 49159b3361Sopenharmony_ci 50159b3361Sopenharmony_ci' get input files 51159b3361Sopenharmony_ciSet wsh = WScript.CreateObject("WScript.Shell") 52159b3361Sopenharmony_ciSet args = WScript.Arguments 53159b3361Sopenharmony_ciIf args.Count = 0 Then 54159b3361Sopenharmony_ci MsgBox "LAME mp3 encoder/decoder frontend script." & vbCR & _ 55159b3361Sopenharmony_ci "Please use drag & drop to specify input files.", vbInformation, title 56159b3361Sopenharmony_ci WScript.Quit 57159b3361Sopenharmony_ciEnd If 58159b3361Sopenharmony_ci 59159b3361Sopenharmony_ci' check path 60159b3361Sopenharmony_ciSet fso = CreateObject("Scripting.FileSystemObject") 61159b3361Sopenharmony_ciIf Not fso.FileExists(path & lame) Then 62159b3361Sopenharmony_ci MsgBox "Could not find LAME!" & vbCR & "(looked for '" & path & lame & "')", vbCritical, title 63159b3361Sopenharmony_ci WScript.Quit 64159b3361Sopenharmony_ciEnd If 65159b3361Sopenharmony_ci 66159b3361Sopenharmony_ci' start GUI 67159b3361Sopenharmony_ciif useGUI Then 68159b3361Sopenharmony_ci set ie=WScript.CreateObject("InternetExplorer.Application", "ie_") 69159b3361Sopenharmony_ci ie.navigate(path & "lameGUI.html") 70159b3361Sopenharmony_ci do 71159b3361Sopenharmony_ci WScript.Sleep 100 72159b3361Sopenharmony_ci loop until ie.ReadyState=4 'wait for GUI 73159b3361Sopenharmony_ci 74159b3361Sopenharmony_ci ie.Width=640 75159b3361Sopenharmony_ci ie.Height=600 76159b3361Sopenharmony_ci ie.Toolbar=false 77159b3361Sopenharmony_ci ie.Statusbar=false 78159b3361Sopenharmony_ci ie.visible=true 79159b3361Sopenharmony_ci 80159b3361Sopenharmony_ci 'link to GUI 81159b3361Sopenharmony_ci set document=ie.document 82159b3361Sopenharmony_ci document.forms.lameform.okbutton.onClick=GetRef("okbutton") 83159b3361Sopenharmony_ci 84159b3361Sopenharmony_ci 'wait for user pressing ok... 85159b3361Sopenharmony_ci do 86159b3361Sopenharmony_ci WScript.Sleep 300 87159b3361Sopenharmony_ci loop until process 88159b3361Sopenharmony_ciend if 89159b3361Sopenharmony_ci 90159b3361Sopenharmony_ci'process files 91159b3361Sopenharmony_ciFor i = 0 To args.Count-1 92159b3361Sopenharmony_ci infile = args(i) 93159b3361Sopenharmony_ci ' check input file 94159b3361Sopenharmony_ci If fso.FolderExists(infile) Then 95159b3361Sopenharmony_ci MsgBox "'" & infile & "' is a folder!" & vbCR & _ 96159b3361Sopenharmony_ci title & " only handles proper files.", vbInformation, title 97159b3361Sopenharmony_ci Else 98159b3361Sopenharmony_ci If Not fso.FileExists(infile) Then 99159b3361Sopenharmony_ci MsgBox "Error opening input-file" & vbCR & "'" & infile & "'", vbCritical , title 100159b3361Sopenharmony_ci Else 101159b3361Sopenharmony_ci ' run lame 102159b3361Sopenharmony_ci If(LCase(getExtension(infile))="mp3") Then 'decode 103159b3361Sopenharmony_ci ret = wsh.Run(Chr(34) & path & lame & CHR(34) & " --decode " & _ 104159b3361Sopenharmony_ci Chr(34) & infile & Chr(34) & Chr(32) & Chr(34) & _ 105159b3361Sopenharmony_ci getBasename(infile) & ".wav" & Chr(34), 1, True) 106159b3361Sopenharmony_ci Else ' encode 107159b3361Sopenharmony_ci ret = wsh.Run(Chr(34) & path & lame & CHR(34) & Chr(32) & opts & Chr(32) & _ 108159b3361Sopenharmony_ci Chr(34) & infile & Chr(34) & Chr(32) & Chr(34) & _ 109159b3361Sopenharmony_ci getBasename(infile) & ".mp3" & Chr(34), 1, True) 110159b3361Sopenharmony_ci End If 111159b3361Sopenharmony_ci ' diagnostics 112159b3361Sopenharmony_ci Select Case ret 113159b3361Sopenharmony_ci Case (0) 'okeydokey 114159b3361Sopenharmony_ci Case (-1) 115159b3361Sopenharmony_ci MsgBox "LAME aborted by user!", vbExclamation, title 116159b3361Sopenharmony_ci Case (1) 117159b3361Sopenharmony_ci MsgBox "Error returned by LAME!" & vbCR & "(Check LAME options and input file formats.)" & vbCR & "Used Options: " & opts, vbCritical, title 118159b3361Sopenharmony_ci Case Else 119159b3361Sopenharmony_ci MsgBox "Received unknown LAME return-code: " & ret, vbCritical, title 120159b3361Sopenharmony_ci End Select 121159b3361Sopenharmony_ci End If 122159b3361Sopenharmony_ci End If 123159b3361Sopenharmony_ciNext 124159b3361Sopenharmony_ci 125159b3361Sopenharmony_ciWScript.Quit 126159b3361Sopenharmony_ci' ******************************************************************* 127159b3361Sopenharmony_ci' utility functions 128159b3361Sopenharmony_ci 129159b3361Sopenharmony_ciFunction getBasename(filespec) 130159b3361Sopenharmony_ci Dim fso 131159b3361Sopenharmony_ci Set fso = CreateObject("Scripting.FileSystemObject") 132159b3361Sopenharmony_ci Set f = fso.GetFile(filespec) 133159b3361Sopenharmony_ci 134159b3361Sopenharmony_ci getBasename = f.ParentFolder & "\" & fso.GetBaseName(filespec) 135159b3361Sopenharmony_ciEnd Function 136159b3361Sopenharmony_ci 137159b3361Sopenharmony_ciFunction getExtension(filespec) 138159b3361Sopenharmony_ci Dim fso 139159b3361Sopenharmony_ci Set fso = CreateObject("Scripting.FileSystemObject") 140159b3361Sopenharmony_ci Set f = fso.GetFile(filespec) 141159b3361Sopenharmony_ci 142159b3361Sopenharmony_ci getExtension = fso.GetExtensionName(filespec) 143159b3361Sopenharmony_ciEnd Function 144159b3361Sopenharmony_ci 145159b3361Sopenharmony_ci' ******************************************************************* 146159b3361Sopenharmony_ci' manage link to IE HTML-interface 147159b3361Sopenharmony_ci 148159b3361Sopenharmony_cisub okbutton 149159b3361Sopenharmony_ci 'process inputs 150159b3361Sopenharmony_ci opts=document.all.lameoptions.Value 151159b3361Sopenharmony_ci ie.Quit 152159b3361Sopenharmony_ci MsgBox "LAME options:" & vbCR & opts, vbInformation, title 153159b3361Sopenharmony_ciend sub 154159b3361Sopenharmony_ci 155159b3361Sopenharmony_cisub ie_onQuit 156159b3361Sopenharmony_ci process=True 157159b3361Sopenharmony_ciend sub 158159b3361Sopenharmony_ci'eof 159