You are not logged in.

#1 2010-11-04 11:51:58

valvet
Member
From: Denmark
Registered: 2009-06-06
Posts: 147

[SOLVED] Pipe output of find into mplayer

Hi

I'm often looking for songs using the find command, copying the result with my dear mouse and playing it in mplayer - how do I automate this a bit, piping it into mplayer automatically?

output

michael@swamp ~/music> find . -iname '*damer*'
./VA-Dance_Chart_Vol_24-2CD-2009-pLAN9/122-julian-damer.mp3

Thanks

Last edited by valvet (2010-11-04 13:10:52)

Offline

#2 2010-11-04 12:25:25

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: [SOLVED] Pipe output of find into mplayer

find . -iname '*damer*' -print0 | xargs -0 mplayer

Offline

#3 2010-11-04 12:27:45

valvet
Member
From: Denmark
Registered: 2009-06-06
Posts: 147

Re: [SOLVED] Pipe output of find into mplayer

ber_t wrote:
find . -iname '*damer*' -print0 | xargs -0 mplayer

Excellent, thank you!

Offline

#4 2010-11-04 13:22:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Pipe output of find into mplayer

I use this:

[karol@black ~]$ type musa
musa is a function
musa () 
{ 
    find /home/karol/music/ -type f -iname "*$1*" -iname "*$2*" -exec mplayer '{}' \;
}

Offline

#5 2010-11-04 19:10:27

colbert
Member
Registered: 2007-12-16
Posts: 809

Re: [SOLVED] Pipe output of find into mplayer

karol wrote:

I use this:

[karol@black ~]$ type musa
musa is a function
musa () 
{ 
    find /home/karol/music/ -type f -iname "*$1*" -iname "*$2*" -exec mplayer '{}' \;
}

That is great! I wonder, how could I change that find line so that the directory/location being searched is also a variable?

Offline

#6 2010-11-04 19:25:20

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Pipe output of find into mplayer

colbert wrote:

That is great! I wonder, how could I change that find line so that the directory/location being searched is also a variable?

You mean like this:

find "$1" -type f -iname "*$2*" -iname "*$3*" -exec mplayer '{}' \;

?
Of course it can be $3, $1, $2 if you first want to say what to look for and next where.

'Find' looks in subfolders and I have all my music in one place, plus I don't want t type things like '/home/karol/blah/foo/bar' every time. If your paths look like this, you can add some variables to this function so that you write e.g. 'musa $music killer queen' and not 'musa /home/karol/music/ killer queen'.
If you don't know how to do this, just ask.

Last edited by karol (2010-11-04 19:34:16)

Offline

#7 2010-11-04 19:32:25

valvet
Member
From: Denmark
Registered: 2009-06-06
Posts: 147

Re: [SOLVED] Pipe output of find into mplayer

Clever looking function, I'll try that out - thanks alot :-)

Offline

Board footer

Powered by FluxBB