I didn't mean to imply that you did anything wrong by not mentioning the shell. It was just an FYI for the next time. But yeah, it does affect what syntax is supported, as the others have pointed out. Also be sure to mention if you're on a non-linux platform, as the versions of the core utilities used in other unixes usually have fewer options than the gnu counterparts.
You likely can't use command substitution in the way you want here (in the find command's -exec option), because there's no simple way to correctly and reliably feed the parameters you want to the commands inside it.
The loop options given before are really your best bet; either that or write an external script or function to call on instead. Use find to feed in the filenames and let the loop/script/function handle everything else.
I did some snooping around the
convert command though, and finally found a way to make it print out the filename with the converted ending.
Code:
find . -iname "*.png" -exec convert "{}" -set filename:namefmt '%d/%t.jpg' 'jpg:%[filename:namefmt]' \;
-set filename:namefmt defines a filename format with the alias "namefmt", and
'%d/%t.jpg' is the format that you want: directorypath/basename.newext. (Don't try to use
%e here, as that's the extension of the input file. I ended up overwriting the original in one test.)
Then
'jpg:%[filename:namefmt]' is the actual output file argument, using that pre-defined pattern. Since there's as yet no file ending that tells the command what format to output as, you have to use the alternate syntax of
format:filename to specify it.
These are the pages that helped me to figure this out:
http://www.imagemagick.org/Usage/files/#save
http://www.imagemagick.org/script/escape.php