How do I operate jpegtran
on a bunch of images at once?
I've not used jpegtran
myself before, but based on your example command you can enter the following at a command prompt:
cd /path/to/where/images/are/stored
for %f in (*.jpg) do jpegtran -copy none -optimize %f %~nf-new.jpg
Note that this assumes you are running from cmd.exe
command prompt; if you are in a batch file the %
s need doubled to %%
.
See the for
reference for more information.
Explanation
for %f in (*.jpg)
- loop through all files ending in .jpg extension using the variable %f
do jpegtran -copy none -optimize
- do
this action (using your example jpegtran
above)
%f
- variable with filename plus extension (original file)
%~nf
- variable with filename without extension as per reference above (new file with -new.jpg
appended)
I never knew about that
– HartleySan – 2015-08-13T01:44:21.067for
command from the Windows command line. Very awesome. It should be noted thatjpegtran.exe
either needs to be in the images folder you're running the command from, or it has to be registered as part of thePATH
environment variable. Also, neither of your links worked, but I found information aboutfor
here.