I’m trying to create a service in automator, which allows me to add files/folders from Finder directly into my mpd playing queue.

I tried the following, the command runs, but nothing happens.

automator mpc-add

Could anyone please help?

PS: My music-directory is $HOME/Music/ – if that’s important …

EDIT: The following code works perfectly in bash, but not as service.

for arg in "$@"; do
  dir=$(cd -P "$(dirname "$arg")" && pwd)/ || continue
  mpc add "${dir#"$HOME/Music/"}$(basename "$arg")"

1 Answer 1


Following code …

for arg in "$@"; do
  dir=$(cd -P "$(dirname "$arg")" && pwd)/ || continue
  /usr/local/bin/mpc add "${dir#"$HOME/Music/"}$(basename "$arg")"

does the trick.

You must log in to answer this question.

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