Ok I post it.
Things to know. I made a direct reference to a folder "C:\Test" in the script. That's where I put the wav files.
If an mp4 encoding misses, the script must be stopped (killing wscript in the task manager, or closing the script windows for cscript), the mp4 files must be deleted before relaunching the encoding (not checked for mp4 presence).
I created an empty.mov file in the QuickTime folder (file-new then save), and load it to avoid QT to load web ad.
I used paths with only one "\", but VBScrit would preferer "\\" at some occasions. I'll have to do it later, store the paths to files both ways. One for internal file handling of VBScript (like for mp5) and one addressed to file inserts in QuickTime, because of course QuickTime won't accept paths with "\\".
For foreign accents, maybe I'll have to send the chars 1 by 1, or maybe I use the bad command.
I'm very new to VBScript. So don't flame me I only tested it with 4 files successive encoding.
Copy the text below and save it in a new text file. Then rename to something like this "encode.vbs"
PS : I forgot to tell that the mp4 encoding will be done with the last settings used in QuickTime.
Also, do NOT do anything when using the script and quit any application that could steal QuickTime's focus. QuickTime is and must stay the frontmost application.
'Batch QuickTime by frdakota@hotmail.com
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
fileCount = 0
For Each f1 In fc
s = s & f1.name
s = s & chr(13)
files(fileCount) = Path & "\" & f1.name
fileCount = fileCount + 1
Next
ShowFolderList = s
End Function
Function WavList(Count)
Dim i, w
w = 0
For i = 0 To Count -1
If LCase(Right(files(i), 3)) = "wav" Then
Wav(w) = files(i)
w = w + 1
End If
Next
WavList = w
End Function
Function CallQuickTime(Path)
Dim fso, mp5
Set fso = CreateObject("Scripting.FileSystemObject")
WScript.Sleep 5000
WshShell.SendKeys "%FO"
WScript.Sleep 1000
WshShell.SendKeys "%D"
WshShell.SendKeys Path
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "%FE"
WScript.Sleep 1000
WshShell.SendKeys "%E"
mp5 = Left(Path, Len(Path)-3) & "mp5"
WScript.Sleep 9000
While fso.FileExists(mp5)
Wend
'The Enter was added in case QuickTime says .wav file already exists, to clear the error.
'I launches playing if all goes well.
WshShell.SendKeys "{ENTER}"
End Function
Dim files(255), fileCount, List, Wav(255), wavCount, Path, ReturnCode
Path = "C:\Test"
List = ShowFolderList( Path )
wavCount = WavList(fileCount)
If wavCount > 0 Then
Set WshShell = WScript.CreateObject("WScript.Shell")
' One \ so I use ~1
WshShell.Run("C:\Progra~1\QuickTime\empty.mov")
' Could be coded "C:\\Program Files\\QuickTime\\empty.mov"
ReturnCode = WshShell.Run("C:\Progra~1\QuickTime\empty.mov", 1, True)
WScript.Sleep 5000
WshShell.AppActivate ("empty.mov")
WScript.Sleep 2000
For i = 0 To wavCount -1
CallQuickTime(wav(i))
Next
Else
Wscript.Echo("No wav files found.")
End If
Wscript.Quit