Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 convert a pdf file to jpg images by using ImageMagick like this:

convert -density 600 foo.pdf foo.jpg

The created jpg images are named foo-1.jpg, foo-10.jpg and so on.

Is there way to 0-pad the output file names to foo-01.jpg etc.?

share|improve this question
up vote 13 down vote accepted

ImageMagick accepts format specifiers in its command line:

convert -density 600 foo.pdf foo-%02d.jpg

Quote from the doc:

Filename References

Optionally, use an embedded formatting character to write a sequential image list. Suppose our output filename is image-%d.jpg and our image list includes 3 images. You can expect these images files to be written:

share|improve this answer

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.