'04/20/2000 - Cyber Punk! AKA Gunslinger ' 'I wrote this script because I hated having to 'convert my 1200 TGA texture files over to 'M32 one by one. ' 'This script file will convert an entire 'directory full of TGA files in to M32 'files assuming a few things are true: ' ' (1) You have the TGA2M32 program. ' (2) This script resides in the same directory as ' both the TGA2M32.EXE file and the Path.ini ' (3) The TGA files are uncompressed 24-bit format ' 'Command line usage is either: ' ' BATCHM32.VBS PATH [DELETE TGA'S (YES|NO)] ' ' example: ' ' BATCHM32.VBS C:\FOLDER_WITH_TGA_FILES YES ' 'Spaces in the directory path / name will cause an 'error since the Windows Scripting Host will pass 'anything seperated by spaces as multiple arguments. ' 'The script was ONLY tested on a Win2K box with, 'of course, IE 5. There should be no problem 'running on a Win9x box or a NT4 box as long as 'you have an up to date scripting run time on 'the system. Which, loosley translated, means 'you should be running IE5. ' 'Script checks for tager folder, TGA2M32.exe and Path.ini. 'Script copies Path.ini to target folder. 'TGA2M32 is run for each and every TGA file in the directory. 'Program signals completion. ' dim sTGAPath 'String dim sDeleteTGA 'Boolean dim sLaunchPath 'String 'Read in target directory and DELETE TGA flag (False by default) ' Call ParseSwitches 'Get Launch Path sLaunchPath = left(WScript.ScriptFullName, len(WScript.ScriptFullName) - instrrev(WScript.ScriptFullName,"\")+1) set oFSO = CreateObject("Scripting.FileSystemObject") 'Ensure target path exists if not oFSO.FolderExists(sTGAPath) then msgbox "The directory you specified " & _ sTGAPath & _ " does not exist. Please " & _ "check your entry and try again.", _ vbOKOnly + vbCritical, _ "TGA Path Error" set oFSO = nothing wScript.quit end if 'Ensure that TGA2M32 exists if not oFSO.FileExists(sLaunchPath & "\TGA2M32.EXE") then msgbox "The TGA2M32.EXE can not be found " & _ "in the current path of " & _ sLaunchPath & ". Please ensure that " & _ "TGA2M32.EXE exists in the same folder " & _ "as this script.", vbOKOnly + vbCritical, _ "File Not Found Error" set oFSO = nothing WScript.quit end if 'Ensure that PATH.INI exists if not oFSO.FileExists(sLaunchPath & "\Path.ini") then msgbox "The TGA2M32.EXE INI file (Path.INI) " & _ "could not be found in the current path of " & _ sLaunchPath & ". Please ensure that " & _ "PATH.INI exists in the same folder " & _ "as this script AND that it contains the " & _ "proper path to the needed .M32 files " & _ "supplied with TGA2M32.", _ vbokonly + vbcritical, _ "File Not Found Error" set oFSO = nothing WScript.quit end if 'Confirm DELETE TGA just in case if sDeleteTGA="TRUE" then dim bResult 'Long bResult = msgbox("Are you sure you want to delete " & _ "each TGA file after it is converted to " & _ "an M32 file?" & chr(13) & chr(10) & chr(13) & chr(10) & _ "This could result in the loss of all TGA files " & _ "should an error occur.", vbYesNo + vbQuestion, _ "Confirm Deletion") if bResult = vbNo then sDeleteTGA ="" end if 'Copy the INI file in to the target path oFSO.copyfile sLaunchPath & "\Path.ini", sTGAPath & "\Path.ini" 'Loop through each TGA file and turn in to M32 dim oFile 'Scripting.File dim oShell 'WScript.Shell set oShell = CreateObject("WScript.Shell") For Each oFile in oFSO.GetFolder(sTGAPath).Files if ucase(right(oFile.Name,3))="TGA" then oShell.Run "tga2m32.exe " & ofile.Name,0,True if sDeleteTGA="TRUE" then oFSO.DeleteFile(oFile.Name) next 'oFile 'Delete INI file oFSO.DeleteFile sTGAPath & "\path.ini" 'Clean up and exit set oFile = nothing set oShell = nothing set oFSO = nothing 'Notify of completion WScript.echo "Conversion complete!" WScript.quit Sub ParseSwitches dim lCount 'Long dim sParam 'String if WScript.Arguments.Count < 1 then exit sub sTGAPath=WSCript.Arguments(0) sDeleteTGA = "FALSE" if WScript.Arguments.Count > 1 then if ucase(WScript.Arguments(1))="Y" or _ ucase(WScript.Arguments(1))="TRUE" or _ ucase(WScript.Arguments(1))="YES" or _ ucase(WScript.Arguments(1))="X" then _ sDeleteTGA = "TRUE" end if end sub