How to get folder path in Automator Folder Action?
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 &quot;Get Parent Folders of Finder Items&quot; in the &quot;File and Folder Automator Action Pack&quot;. 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 &quot;Finder&quot; 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.)