The program doing the shrinking in the script is pdfs which is the command line interface for the 3-rd party app “PDF Squeezer”. I recommend you look in the options for pdfs to see how to decript:compress:re-encrpt and adjust the script accordingly. The encryption password must be known to you of course to do this.
I am impressed with “PDF Squeezer” and find it a good companion to DEVONthink, but I drag and drop pdf’s into and then compress to the degree I want, then saving back to DEVONthink. I’ve never tried encrypted files with the manual method, nor have I been able to get pdfs to work as “PDF Squeezer” throws an intelligible error message when I try to “authenticate” it.