More precisely: Given a folder containing images in pdf-format (each of which has a name of the form NAME.pdf, with NAME being composed of several words separated by spaces), how do I batch convert the images to jpg-format and preserve their names in the form NAME.jpg ? (Using pdftoppm as indicated in "How to convert a .pdf file into a folder of images?" seems rather complicated, since it requires treating each image separately.)


You can use convert from imagemagick to convert a PDF into an image.

To install it, use the following command:

sudo apt-get install imagemagick 

To convert all PDFs in a directory, go to that directory and run the following command:

for i in *.pdf; do convert "$i" "${i%.*}.jpg"; done

ImageMagick documentation | Bash string manipulation

  • That will not work for files with spaces in the name ("NAME being composed of several words separated by spaces). You have to quote the variables. – Panther Oct 1 '13 at 19:57
  • I've edited the answer to reflect this. – SirCharlo Oct 1 '13 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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