Код:
![Выделить весь код](images/misc/selectcode.png)
Option Explicit
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim strSourceFile
Dim objFile
If WScript.Arguments.Count = 1 Then
strSourceFile = WScript.Arguments.Item(0)
With WScript.CreateObject("Scripting.FileSystemObject")
If .FileExists(strSourceFile) Then
Set objFile = .GetFile(strSourceFile)
Select Case LCase(.GetExtensionName(objFile.Name))
Case "jpg", "jpeg", "jpe"
With WScript.CreateObject("ADODB.Stream")
.Type = adTypeBinary
.Open
.LoadFromFile objFile.Path
.Position = objFile.Size - 1
If AscB(MidB(.Read(1), 1, 1)) = &H0A Then
.Position = objFile.Size - 1
.SetEOS
.SaveToFile objFile.Path, adSaveCreateOverWrite
Else
WScript.Echo "Last byte of source file [" & strSourceFile & "] is not a 0x0A value."
End If
.Close
End With
Case Else
WScript.Echo "Source file [" & strSourceFile & "] probably not a jpeg file."
WScript.Quit 3
End Select
Else
WScript.Echo "Can't find source file [" & strSourceFile & "]."
WScript.Quit 2
End If
End With
Else
WScript.Echo "Usage: " & WScript.ScriptName & " <Source file>"
WScript.Quit 1
End If
WScript.Quit 0