Individually execute all files in a directory

I am trying to write a shell script to move a directory tree and play every mp3 file that it finds. afplay is my choice utility, given that I am on a mac. However, afplay only takes one argument at a time, so you need to call it over and over again if you want it to continue playing. It seems that the simplest solution would be the following:

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

... but something is stopping you from escaping quotes. For a quick reference, \ 047 is the octal for '(single quotation mark), which should encapsulate the arguments into one, but for some reason this is not the case. I do not know what is going on here.

+3
source share
2

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

+5

:

1. song_name.mp3
2. song_name.mp3
3. song_name.mp3  
  ...
20. song_name.mp3

20 ,

for ((i=1; i<=20; i++)); do afplay $i* ; done
0

Source: https://habr.com/ru/post/1728404/


All Articles