tags:

views:

40

answers:

1

I've been trying to write a shell script to travel a directory tree and play every mp3 file it finds. afplay is my utility of choice, given that I am on a mac. However, afplay only takes one argument at a time, so you have to call it over and over again if you want it to keep playing. It seems like the simplest solution would be as follows:

$(`find . -name *.mp3 | awk '{ print "afplay \047" $0 "\047"; }' | tr '\n' ';' | sed 's/;/; /g'`)

...but something keeps getting caught up in the escaping of quotes. For quick reference, \047 is octal for ' (the single quote character), which should encapsulate arguments into one, but for some reason it is not. I have no clue what is going wrong here.

+1  A: 

Why not just find . -name '*.mp3' -exec afplay '{}' \;?

Alex Martelli
beautiful, thank you.
Davis Gallinghouse