Automator choose finder folder and run shell script
You can simply pass the selected folder to the shell script by selecting "as argument" from the "pass input:" dropdown-menu and then adding "$@" at the point in your script where you want the folder path to be used. 

To use drag&amp;drop, just remove the "ask for finder items" action and let the "run shell script" receive the input from "application can receive files and folders as input".