Last active
December 21, 2015 22:59
-
-
Save penguin2716/6378850 to your computer and use it in GitHub Desktop.
I want to play my mp3 files in random order!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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