4

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

Is there an easy way to achieve this?

7

You can achieve this with a Nautilus script.

First install a ruby package

sudo apt-get 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 ~/.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.

  • 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
0

Well, this end up working for me:

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

:) Yupi.

  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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