1
' lame.vbs WindowsScript wrapper v0.5, 06/15/2001
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.
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!
16
' You may wish to create copies of this file with different options set.
18
' If you would like a GUI: try to enable the HTML UI (see below)
20
' Ralf Kempkens, ralf.kempkens@epost.de
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
29
' * experimental HTML UI support (disabled by default)
30
' V0.2 added multiple file support
31
' V0.1 initial release
33
' *** change path to your needs ***
34
path = "D:\Audio\Lame\Lame386\" '!!! must end with a backslash !!!
37
' *** change default options to your needs ***
38
opts = "--preset hifi"
40
' *** HTML GUI (experimental) ***
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.
45
' no changes needed below this line
46
' ##########################################################################
47
Dim wsh, args, infile, fs
51
Set wsh = WScript.CreateObject("WScript.Shell")
52
Set args = WScript.Arguments
53
If args.Count = 0 Then
54
MsgBox "LAME mp3 encoder/decoder frontend script." & vbCR & _
55
"Please use drag & drop to specify input files.", vbInformation, title
60
Set fso = CreateObject("Scripting.FileSystemObject")
61
If Not fso.FileExists(path & lame) Then
62
MsgBox "Could not find LAME!" & vbCR & "(looked for '" & path & lame & "')", vbCritical, title
68
set ie=WScript.CreateObject("InternetExplorer.Application", "ie_")
69
ie.navigate(path & "lameGUI.html")
72
loop until ie.ReadyState=4 'wait for GUI
81
set document=ie.document
82
document.forms.lameform.okbutton.onClick=GetRef("okbutton")
84
'wait for user pressing ok...
91
For i = 0 To args.Count-1
94
If fso.FolderExists(infile) Then
95
MsgBox "'" & infile & "' is a folder!" & vbCR & _
96
title & " only handles proper files.", vbInformation, title
98
If Not fso.FileExists(infile) Then
99
MsgBox "Error opening input-file" & vbCR & "'" & infile & "'", vbCritical , title
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)
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)
115
MsgBox "LAME aborted by user!", vbExclamation, title
117
MsgBox "Error returned by LAME!" & vbCR & "(Check LAME options and input file formats.)" & vbCR & "Used Options: " & opts, vbCritical, title
119
MsgBox "Received unknown LAME return-code: " & ret, vbCritical, title
126
' *******************************************************************
129
Function getBasename(filespec)
131
Set fso = CreateObject("Scripting.FileSystemObject")
132
Set f = fso.GetFile(filespec)
134
getBasename = f.ParentFolder & "\" & fso.GetBaseName(filespec)
137
Function getExtension(filespec)
139
Set fso = CreateObject("Scripting.FileSystemObject")
140
Set f = fso.GetFile(filespec)
142
getExtension = fso.GetExtensionName(filespec)
145
' *******************************************************************
146
' manage link to IE HTML-interface
150
opts=document.all.lameoptions.Value
152
MsgBox "LAME options:" & vbCR & opts, vbInformation, title