for dir in ./*/ # list directories in the form "./dirname/"
do
dir=${dir%*/} # remove the trailing "/"
cd ${dir} # go in subfolder
zmv '(*).pdf' '${1//(#m)<->/${(l[3][0])MATCH}}.pdf' # do the renaming
cd .. # return to main folder
done