Skip to content

Instantly share code, notes, and snippets.

@penguin2716
Last active December 21, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penguin2716/6378850 to your computer and use it in GitHub Desktop.
Save penguin2716/6378850 to your computer and use it in GitHub Desktop.
I want to play my mp3 files in random order!
#!/usr/bin/env ruby
#-*- coding: utf-8 -*-
# I want to play my music files in random order!
# command example:
# find . -name '*.ogg' | sort -R | each.rb mplayer -cache 1024 {}
# I didn't know the command above can be replaced to...
# find . -name '*.ogg' -print0 | sort -z -R | xargs mplayer -cache 1024
if ARGV.size == 0
puts "usage: #{$0} args.."
exit 1
end
while STDIN.gets
filename = $_.sub("\n", '')
if ARGV.include? '{}'
system "#{ARGV.join(' ').sub(/{}/, "'#{filename}'")}"
else
system "#{ARGV.join(' ')} '#{filename}'"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment