How to use JpegTran to recursively process all images by overwriting them in a directory using Windows?

Now I have the following batch file that I use to process my images:

@echo none cd %1 md "%~1\ProcessedJPEGS" for %%i in (*.jpg) do "C:\Program Files\Image Optimization\jpegtran.exe" -optimize -progressive -copy none "%%i" "%~1\ProcessedJPEGS\%%i" move /Y "%~1\ProcessedJPEGS\*.*" "%~1" rd "%~1\ProcessedJPEGS" pause 

As you can see, this is not perfect, but my skills are ridiculous at best, so I need help here :)

What I want to do is run this batch in a directory and recursively process all the images and overwrite them.

Thanks in advance, Arky

+3
source share
1 answer

Based on your command line, this should process all JPG files from the current folder and below. Check it out on a sample set of files / folders to make sure it works for you.

 @echo none for /f "delims=" %%a in ('dir "*.jpg" /b /s /a-d') do ( echo processing "%%a" "C:\Program Files\Image Optimization\jpegtran.exe" -optimize -progressive -copy none "%%a" "%%a.tmp" move /Y "%%a.tmp" "%%a" >nul ) pause 
+8
source

Source: https://habr.com/ru/post/1499128/


All Articles