Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created March 11, 2011 13:31
Show Gist options
  • Select an option

  • Save xulapp/865879 to your computer and use it in GitHub Desktop.

Select an option

Save xulapp/865879 to your computer and use it in GitHub Desktop.
jpegtran
@echo off
:mainloop
if "%~1" == "" goto :eof
call :optimize "%~1"
shift
goto :mainloop
:optimize
set a=%~a1
if "%a:~0,1%" == "d" (
for /r "%~1" %%i in ("*.jpg", "*.jpeg") do call :optimize "%%~i"
goto :eof
)
set tmpfile="%temp%\optjpgtmp-%random:~-1%%random:~-1%%random:~-1%%random:~-1%%random:~-1%.jpg"
jpegtran.exe -copy none -progressive "%~1" %tmpfile%
copy /y %tmpfile% "%~1"
del %tmpfile%
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment