I use Terminal to run a command. It runs fine from the command line, but I want to be able to automate it with Automator. The syntax of the command (of course, minus the quotes) is as follows:

 spotify-ripper user.name "/path/to/directory" "spotifyURI" 

I've tried countless times to get Automator to:

  1. Ask for finder items (to create the "path/to/directory")
  2. Ask for Text (asking me to past in the URI/URL link from spotify)
  3. Run Shell Script (/bin/bash)

    spotify-ripper user.name "$@"

I have tried it with "Pass input" to "stdin" or "as arguments". Just get an error. I've read that "$@" will pass both variables one after the other which just what I need. I've also tried "$1" "$2" as some posts have suggested. What am I missing? I just want to pass path info and a URL to the end of a shell command, but nothing seems to work. I've tried the GET and SET Variable options, but that doesn't seem to help either.

Anyone have any ideas what I should be doing?

1 Answer 1


There are multiple ways to solve this problem. One way is already described in the question Automator variable in shell script (make sure to enable the options precisely as follows):

  1. Ask for Finder Items (Type: Folders)
  2. Set Value of Variable (Variable [example]: Directory-Path)
  3. Ask for Text (Checked: Ignore this action's input; Checked: Require an answer)
  4. Set Value of Variable (Variable [example]: Spotify-Url)
  5. Get Value of Variable (Variable: Directory-Path; Checked: Ignore this action's input)
  6. Get Value of Variable (Variable: Spotify-Url)
  7. Run Shell Script (Pass input: as arguments; Content: export PATH=/usr/local/bin:$PATH ; /path/to/spotify-ripper user.name "$1" "$2"—change the "/path/to" part with the real path to spotify-ripper, of course: probably /usr/local/bin/spotify-ripper)

Another way is to use AppleScript, either in a "Run AppleScript" action in Automator or as an AppleScript application saved in AppleScript Editor. Here's an example in AppleScript:

on run
        set spotifyDialog to display dialog "Enter a Spotify URL:" buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel" default answer "https://" with title "Spotify Ripper"
        if the button returned of spotifyDialog is "OK" then
            set spotifyURL to text returned of spotifyDialog
            choose folder with prompt "Choose a folder:"
            set theDirectory to the result
            do shell script "export PATH=/usr/local/bin:$PATH ; /path/to/spotify-ripper user.name " & quoted form of POSIX path of theDirectory & space & spotifyURL
        end if
    end try
end run
  • that is amazing - but now just can't work out what the path to the application is. It was installed via Homebrew, so not sure where it was installed. Mar 16, 2017 at 22:08
  • @MarkMonahan In Terminal, which spotify-ripper will tell you the path to spotify-ripper if it's in your PATH. If for some strange reason it's not in your PATH but you know it's in /usr, find /usr -name "spotify-ripper" 2>/dev/null should tell you the path also. If my answer above worked for you, don't forget to mark the answer as accepted.
    – Big Mac
    Mar 17, 2017 at 20:04
  • Thanks for all your input on this. To complicate matters, it continues to report an error with the shell script. When I run it through the Apple Script method above it says a required dependency is missing (Lame) and tells me to install it and add it to the PATH. Lame is already installed and works fine when spotify-ripper is run from the normal command line. Any ideas why it can't see dependencies when running through Apple Script? Apr 3, 2017 at 15:39
  • @MarkMonahan AppleScript runs shell scripts using sh, which doesn't use the PATH variable from bash (the interactive shell in Terminal). If you installed lame with Homebrew, then in the AppleScript change do shell script "/path/to/spotify-ripper user.name " to do shell script "export PATH=/usr/local/bin:$PATH ; /path/to/spotify-ripper user.name " (changing the "/path/to" part, of course). That will tell sh where to find lame. If that doesn't work, let me know.
    – Big Mac
    Apr 4, 2017 at 13:46
  • Yes, lame was installed via Homebrew. Still can't get it work via Apple Script (I now get errors which seem more linked to Spotify-ripper having issues), but it now works in Automator when I add the PATH line to the "Run Shell Script" - I'll call that a success! Thanks so much for your patience and help Apr 5, 2017 at 7:25

You must log in to answer this question.

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