I've created an Automator Workflow which can take the selected Finder item (being a PDF) and encrypt it using the Apple-provided "Encrypt PDF Documents" action. The problem with this action is it leaves the file buried deep in the /private/var folder structure.

I can add a subsequent action to move the file to a more visible location, however I want to be able to put it back wherever the original file was. Can I do this in Automator?

I tried a set then get of a variable for the filename but the final step to move the file errors with "the chosen folder was not found on this computer". It would seem that it's being given the full original path of the file, which indeed is not a folder.

The intended use of this Workflow is to be used as part of a Hazel action (by stripping off the initial Get Finder Items action). Can anyone tell me how I can solve this problem of encrypting an existing PDF in situ?

Possible options I have thought of include: 1. Figure out how to strip the file name off the variable. 2. Figure out how to encrypt the PDF using AppleScript (and thus making the variable handling much more flexible) 3. Use some other method from within Hazel than Automator/AppleScript.

Please note I am aware of the scripts out there to use PDFPen, but I do not like the fact that PDFPen has to launch just to encrypt a PDF, especially when the OS has the capability built in.

I am something of a novice with both Automator and AppleScript but am a programmer by trade, so any suggestions welcome.

1 Answer 1


I would go with option #2.

You can use command line tools to handle the encryption. A quick google search reveals a free, for non-commercial use, tool


which you can call using applescript like this:

do shell script "cpdf -encrypt AES \"pass\" \"\" in.pdf -o out.pdf"

This way there are no dialog boxes to enter a password. It will encrypt them with the same one if that is ok. Less secure but more convenient.


  • Thanks! That looks like a simple way forward. I will have a go with that tool. Thanks especially for providing the sample AppleScript - it's often the basics that trip noobs like me up. :-)
    – zkarj
    Commented May 7, 2014 at 9:10
  • I have it working now. Brilliant.
    – zkarj
    Commented May 11, 2014 at 3:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .