Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

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.)

share|improve this question

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

share|improve this answer
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. – bodhi.zazen Oct 1 '13 at 19:57
I've edited the answer to reflect this. – SirCharlo Oct 1 '13 at 20:20

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.