In a for loop it is possible to use the features described in man bash
at
Parameter Expansion
...
${parameter%word}
${parameter%%word}
Remove matching suffix pattern. The word is expanded to produce a pattern just
as in pathname expansion. If the pattern matches a trailing portion of the
expanded value of parameter, then the result of the expansion is the expanded
value of parameter with the shortest matching pattern (the ``%'' case) or the
longest matching pattern (the ``%%'' case) deleted. If parameter is @ or *,
the pattern removal operation is applied to each positional parameter in turn,
and the expansion is the resultant list. If parameter is an array variable
subscripted with @ or *, the pattern removal operation is applied to each member
of the array in turn, and the expansion is the resultant list.
The following one-liner should do the job
for f in ./*.jpg ; do convert "$f" -resize 1200x900 "${f%.jpg}-small.jpg" ; done
This works in bash
, which is the standard shell of Ubuntu. I think it is easier to remember than the elegant method by Steeldriver (who uses only convert
and no for
construct).