Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can`t make this work. I have a lot of images and i want to rename his name and append image size to name using exiv2

exiv2 pr * prints all info about file

# exiv2 pr 9b523e5a002268fe5067a928
File name       : 9b523e5a002268fe5067a928
File size       : 356433 Bytes
MIME type       : image/jpeg
Image size      : 1920 x 1200

Now i want rename my file to look like


I already make something like this

exiv2 pr * | grep "Image " | awk -F':' '{ print $2 }' | sed 's/ //g'

It gives me the image size, but how do i extend this to get the image MIME type to get the .jpeg correct ?

share|improve this question
up vote 6 down vote accepted

Use exiftool instead:

exiftool -ext '' '-filename<%f_${ImageSize}.${FileType}' .

Would rename all the images in the current directory (.).

share|improve this answer
Flexibility of this Exiftool command is so power full. It looks like i don`t need any other tool anymore for many of my actions. – BrutalApple Oct 11 '12 at 13:15
Nice! I had a slightly different usecase and used exiftool -ext '*' '-filename<%f_${ImageSize}.%le' to get lowercase extensions and apply to images with any extension. – kvz Sep 17 '15 at 11:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.