46

If I convert my images with

convert -quality 80% *.jpg

It works, but the software changes the file names to the first one it picks. How can I keep the name or even replace the previous image with that of a lower quality.

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
Frank Vilea
  • 8,323
  • 20
  • 65
  • 86

3 Answers3

90

Try this instead:

mogrify -quality 80% *.jpg
Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
16

convert command help:

convert input-file [options] output-file

Now a little script to convert all jpg files to 80% quality of original under current directory

for file in *.jpg; do
  convert "$file" -quality 80% "$file"
done;
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
ring bearer
  • 20,383
  • 7
  • 59
  • 72
3

This will work for you.

convert -quality 80% '*.jpg' -set filename:original %t %[filename:original].jpg
David Jung
  • 376
  • 5
  • 8