tonytraductor (tonytraductor) wrote in shell_scripting,
tonytraductor
tonytraductor
shell_scripting

shuffledown.

Maybe you guys can help me with something.
I wrote this to play tunes in mplayer, I just cd to the directory and type "tocar" (which I named the script, in /usr/local/bin, meaning "to play in spanish and portuguese).

find . -type f -exec mplayer {} \;

simple enough.

But, I'd like to be able to shuffle and loop.
Now, so long as I have a list to feed mplayer, I should be able to do:
mplayer $pl -shuffle -loop 0
to my knowledge, to get it to shuffle and loop the list.
In fact, I know it works, because I used precisely
exec mplayer $::playlist -shuffle -loop 0
in TclTunes a little tcl/tk gui front end I made for mplayer (as if there weren't enough front ends for mplayer already...)
Doing
find . -type f -exec mplayer -shuffle -loop {} \;
however, doesn't work, since mplayer is getting the input from find, apparently, on file at a time, and, thus,
insists on playing them all in order, then giving up, rather than looping.

Now, in tcl I just appended file names to a list to create a list ($::playlist), but, I did it by choosing one file at a time.
It's a gui, so I used a file selection dialog and did lappend $::playlist for each entry.
What I want with this one is to simply be able to cd to a dir and type the command (calling this one "shuffledown"), and get it to play/shuffle/loop all files in that dir AND subdirs, recursively.
Doing simply
You'd think I could just cd to the dir and do
mplayer -shuffle -loop 0
but it doesn't go past that dir into the subdirs.
If there were a way to get mplayer to play the dirs recursisvely, clearly, that matter would be simple, but, I have not found a means to do that.

I've tried:,

playlist = $(ls -R -1)
mplayer $playlist -shuffle -loop 0


playlist = $(find . -type f)
mplayer $playlist -shuffle -loop 0

I even tried
find . -type f > playlist
$playlist = $(cat playlist)


and not one has yet been productive.

I just want a little bash script.
  • Post a new comment

    Error

    default userpic
  • 8 comments