Hazel - Join PDF Files

I have found a qpdf script to combined pdf files. However, I get an error. Any idea how to make this script work?

for f in $1; do qpdf --empty "${f%.pdf}-joined.pdf" --pages "${f%.pdf}"*.pdf --; done

The error does not tell me much: “less than a minute ago : Error processing shell script on file 1.pdf.”

However, running this command in Terminal works.

qpdf --empty --pages *.pdf '--' output.pdf