How to use JpegTran to recursively process all ima

2019-04-11 19:19发布

Right 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 ideal but my skills are laughable at best so I need some help here :)

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

Thanks in advance, Arky

1条回答
贪生不怕死
2楼-- · 2019-04-11 20:04

Based upon your command line, this should process all JPG files from the current folder and below. Test it on a sample set of files/folders to be 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
查看更多
登录 后发表回答