I'm writing a small bash script to convert a pdf into a series of png images (one for each page of the pdf). This works almost perfectly:
Code:
#!/bin/bash
OUT=./pdf_png_convert/
mkdir $OUT
pdftoppm -r 300 $1 $OUT`basename $1 .pdf`
exit
find $OUT -iname *.PPM -exec convert '{}' `basename '{}' .ppm`.png \;
find $OUT -iname *.PPM -exec rm '{}' \;
mv $OUT/* .
However, the reduction of the final image name to .png using basename doesn't work. I'm left with .ppm.png files.
I know I can work around this quite easily by doing the convert then rename afterwards to fix the extensions, but this seems like it might be a bug in find. I reduced this to the following test case:
Code:
$ find -iname *.PPM -exec basename {} .ppm \;
test-000001
vs.
Code:
$ find -iname *.PPM -exec echo `basename {} .ppm` \;
./test-000001.ppm
I'm no bash guru, but is this a bug in find, or just my understanding of the -exec syntax? Any thoughts?
Thanks
Matthew