How to Optimize JPEG & PNG Images Using jpegtran & OptiPNG in Windows

You may also like...


  1. Maxime says:

    how can i change the outfile directory with this batch, because if i do something like :

    forfiles /s /m *.jpg /c “cmd /c @\”C:\Program Files\Image Optimization\jpegtran.exe\” -copy none -optimize -progressive -outfile C:\path\to\my\output\directory\@file @file”

    This is not working …

    Thanks for your help !

    • Try surrounding the output file path with double quotes like so:

      forfiles /s /m *.jpg /c "cmd /c @\"C:\Program Files\Image Optimization\jpegtran.exe\" -copy none -optimize -progressive -outfile \"C:\path\to\my\output\directory\\@file\" @file"
  2. shrinivas says:


    I get the following error –

    ERROR: Invalid argument/option – ‘*.jpeg’

    any idea what am I doing wrong?


  3. Paul McCollam says:

    Thanks for the tutorial!

    However, I’m getting an error:
    “‘forfiles’ is not recognized as an internal or external command, operable program or batch file.”

    Any ideas?

    Windows 7 64 bit

Leave a Comment

Wrap your code block in <pre class="code"></pre> tag.