Macos – Automator – Set Selected Folder Path as Variable

automatormacososx-mountain-lion

I'm trying to setup an Automator service that would download a list of URLs to the currently selected folder, or wherever the service was ran from. The only problem is I don't see how I would go about setting the currently selected folder as a path to download the files to. I'm thinking of something like this:

Screenshot of my Automator idea

Note: Just realized I had service receives selected as "TEXT in ANY APPLICATION" in my screenshot. This will be "FOLDERS in FINDER" when I hopefully get this figured out!

Where currentFolder currently selected folder, or wherever the service was ran from. As far as I can tell, I would just need to somehow set the currently selected folder as a variable like currentFolder, then set the Download URLs location to that variable? Let me know if I need to explain anything further!

Best Answer

So I took a slightly different route, and just setup a shell script. Apparently cd "$@"; will get the current directory. View a picture of my new automator service workflow.

Basically, I created a new service in Automator, then set Service Receives Selected to "files or folders" in "Finder", and added a "Run Shell Script" to the workflow. I set Shell to "/bin/bash", and Pass Input to "as arguments", then placed the following in the script editor.

cd "$@";
curl -O http://www.example.com/file1.zip
curl -O http://www.example.com/file2.zip
curl -O http://www.example.com/file3.zip
unzip \*.zip
rm *.zip

Now I can right click on any folder, and download my list of files.

Related Question