- 'Convert bmp file(batch) type to JPG
- 'http://www.experts-exchange.com/questions/21969652/Convert-bmp-file-batch-type-to-JPG.html
- ' File Name:BmpToJpg.vbs
- Const xlHtml = 44: Dim Args, pPath
- Set Args = WScript.Arguments
- If Args.Count <> 1 Then WScript.Quit
- If LCase(Right(Args(0), 4)) <> ".bmp" Then WScript.Quit
- pPath = WScript.ScriptFullName & "\..\"
- With CreateObject("Excel.Application")
- With .Workbooks.Add(1)
- With .ActiveSheet
- .Pictures.Insert(Args(0)): .Shapes(1).Cut
- .PasteSpecial "Picture (JPEG)"
- End With
- .SaveAs pPath & "Temporary.htm", xlHtml: .Close False
- End With
- .Quit
- End With
- With CreateObject("Scripting.FileSystemObject")
- .CopyFile pPath & "Temporary.files\image001.jpg", _
- Replace(oPath, ".bmp", ".jpg", 1, -1, 1)
- .DeleteFile pPath & "Temporary.htm"
- .DeleteFolder pPath & "Temporary.files", True
- End With
复制代码
|