Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would love to, while on a given folder, right-click on it and choose play, to play all musics on that folder (and subfolder if any).

Is there an easy way to achieve this?

Thanks a lot

share|improve this question
add comment

3 Answers 3

You can achieve this with a Nautilus script.

First install the package ruby-1.9.1 install ruby-1.9.1.

Then copy this text into a text editor and save the file in ~/.gnome2/nautilus-scripts. Call it something like 'Play'.

#!/usr/bin/env ruby1.9.1
require 'find'

PLAYER = "banshee"
PLAYER_OPTIONS = ["--play-enqueued"]

def play *f
    IO.popen [PLAYER, *PLAYER_OPTIONS, *f] do |io|
        io.read
    end
end

def is_audio f
    begin
        io = IO.popen ['file', '--mime-type', f]
        op = io.read.split(' ')
        r = op[op.length-1] =~ /audio/
        io.close
        r
    rescue
    end
end

files = []

ARGV.each do |f|
    if File.directory? f
        Find.find f do |f|
            files << f if is_audio(f)
        end
    else
        files << f if is_audio(f)
    end
end

play(*files)

Open up ~/.gnome2/nautilus-scripts in the file manager, right click on the file, click properties and make it executable.

You can now right click on some files and select scripts -> Play to play all of the music files you have selected.

share|improve this answer
    
I've followed everything but, nothing happens when I select scripts -> Play :( It doesn't even open banshee. –  MEM Apr 30 '11 at 9:54
    
This definitely works. Make sure you copied the whole of the text. It is very easy to miss of the last line when you select the text. You may find it easier to copy from paste.ubuntu.com/601332 –  dv3500ea Apr 30 '11 at 13:57
    
Nope. I don't doubt the script work. But it not even starts the program, so even if I didn't add the last line (that I did), it should at least open it. I've remake the steps. No luck. Perhaps something to do with my own system configuration somehow. –  MEM Apr 30 '11 at 15:52
    
I've called Play. No extension. Should I called it Play.sh or something ? Or Play.rb ? –  MEM Apr 30 '11 at 15:56
    
The extension makes no difference. As long as you have ruby-1.9.1 installed and the file is made executable, this should work. I don't really know what's going wrong. –  dv3500ea Apr 30 '11 at 21:10
show 1 more comment
up vote 0 down vote accepted

Well, this end up working for me:

http://mundogeek.net/nautilus-scripts/#nautilus-play-banshee

:) Yupi.

share|improve this answer
    
If the script provided by dv3500ea works on all (or almost all) ubuntu systems and not in mine, I will switch the answer for his post instead of this. However, this was, in fact the solution found. –  MEM May 2 '11 at 19:05
add comment

This is probably silly answer but I just right clicked and selected "Open With Other Application... " then I selected my music player which is Audacious. Only drawback is that now every folder has an option to open with Audacious but I'm ok with that.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.