Skip to content

Instantly share code, notes, and snippets.

@miyamae
Created February 18, 2016 08:21
Show Gist options
  • Save miyamae/95f831eab8bea4593eac to your computer and use it in GitHub Desktop.
Save miyamae/95f831eab8bea4593eac to your computer and use it in GitHub Desktop.
下層ディレクトリ内のファイルをランダムに選択して開く(Mac)
#!/usr/bin/env ruby
Dir.chdir(File.expand_path('..', __FILE__)) do
files = Dir.glob('**/*.{mp3,wma}')
file = files[rand(files.size)]
puts file
system "open \"#{file}\""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment