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!


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.

  • This will only work if you select one folder. $@ expands to all arguments passed to the script, so if you select multiple folders or even files, cd doesn't know what to do with them. I'll try and see if I can come up with an alternative. – slhck Aug 23 '13 at 7:47

You can set a env to current dir with this command:


you can then export it

$export currentDir
  • Thank you very much for your answer sajjadG! I'm not very familiar with the Automator program, so I'm sorry beforehand if this should be pretty obvious, but would I place the commands you've listed in as an AppleScript or a Shell Script? Also, in what order would I place these? I would assume $currentDir=$PWD at the very start, and $export currentDir just before setting the download location? – Kelly Lawrence Aug 22 '13 at 17:23
  • @KellyLawrence sorry but I am not familiar with automator but wikipedia says that both of them will work. automaro can use both unix command line scripts (which is what I posted) and AppleScripts. – sajjadG Aug 22 '13 at 17:41
  • No worries @sajjadG! I appreciate you taking the time to provide an answer. As you can see in my answer below, I took a slightly different approach after doing some more research, but the end goal was achieved, regardless! – Kelly Lawrence Aug 23 '13 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.