I use the following command to extract pages from PDF files into independent JPG files before inserting them into videos:

convert.exe -density 96 -resize 640x480 input.pdf +adjoin -alpha remove -alpha off output.jpg

As a result, files are numbered output-1.jpg, output-2.jpg and so on, which means that for PDFs that have more than 10 pages, the first ten are not listed first.

I'd rather that the filenames be numbered as output-01.jpg, output-02.jpg so they come before the rest of the files.

Does someone know if ImageMagick can be told to use two digits when naming output files?

Thank you.


You can use the following:

convert.exe -density 96 -resize 640x480 input.pdf +adjoin -alpha remove -alpha off output-%02d.jpg

The %02d makes sure the number is zero padded to 2 digits.

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.