Dim newSize,dstFile ' edit variables here startRes=1024 ' start the first resize at this resolution. maxRes=256 ' resize to this resolution ' location of irfanview iView=chr(34) & "c:\Program Files\IrfanView\i_view32.exe" & chr(34) ' script starts here If Wscript.Arguments.Count = 0 Then wscript.echo "enter filename as argument" wscript.quit End If myFile=wscript.arguments(0) 'myFile=chr(34) & wscript.arguments(0) & chr(34) wscript.echo "Processing : " & myFile Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") ' this does not work on network drives If Not objFSO.FileExists(myFile) Then Wscript.Echo "The file does not exist." Wscript.Quit End If blabla=reSize(myFile,startRes) wscript.echo "nwfile is: " & newSize Do Until newSize <= maxRes wscript.echo "too big, deleting " & dstfile objFSO.DeleteFile(dstFile) startRes=startRes-25 blabla=reSize(myFile,startRes) wscript.echo "nwfile is: " & newSize Loop wscript.echo "done" Function reSize(reSizeMe,toRes) ' dstFile=Left(reSizeMe,Len(reSizeMe)-1) & "_" & toRes & ".jpg" & chr(34) dstFile=reSizeMe & "_" & toRes & ".jpg" wscript.echo "Resizing " & reSizeMe & " to: " & toRes & " px. as " & dstFile runstring=iView & " " & reSizeMe & " " & "/resample /resize=(" & toRes & ",0) " & _ "/aspectratio /convert=" & dstFile objShell.Run(runstring), 1, TRUE wscript.echo "Getting size of " & dstFile Set nwFile=objFSO.GetFile(dstFile) newSize=Int(nwFile.Size/1024) ' wscript.echo "infunc: " & newSize End Function