How do I get a path (or a name) of the folder an Automator Folder Action is attached to and save it into a variable?

My folder action is attached to Downloads, I copy newly dropped files into a temporary folder, process them and want to move them back into Downloads. I don't want to use hardcoded value with Move Finder Items as the folder action may be attached to different folders. Instead, I need folder action to be smart enough to move items back to the folder it is attached to.

1 Answer 1


I don't think you can get the folder an action is attached to, but I think a good analog would be to get the parent folder of the current file. So, the parent folder of a file in ~/Downloads/MyDownloadedFile.pdf will be the Downloads folder, and you could save that to a variable.

This action is not built in to Automator. However, if you are running macOS 10.13 or earlier, you can purchase a package of third-party Automator Actions from http://automatedwork.server323.com/products/apps/automator-actions-for-mac-os-x-10-610-7-snow-leopard-lion/. The action you want is "Get Parent Folders of Finder Items" in the "File and Folder Automator Action Pack". At the time that I bought it (a few months ago), the developer charged $20.

(You may also be able to accomplish this without third party actions by using an Applescript block—something like tell application "Finder" to return container of (input as alias). However, when I tried this myself, Automator seemed unable to save the variable properly. I'm not sure if that's due to a limitation of Automator or a problem with my Applescript.)

  • Wow, and I just give my Automator actions away...
    – red_menace
    Aug 12, 2020 at 19:12
  • It'll be a problem with your AppleScript.
    – CJK
    Aug 14, 2020 at 23:19

You must log in to answer this question.

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