Mega Code Archive

 
Categories / Ruby / File Directory
 

Find the MP3s

require 'find' module Find   def match(*paths)     matched = []     find(*paths) { |path| matched << path if yield path }     return matched   end   module_function :match end Find.match('./') { |p| ext = p[-4...p.size]; ext && ext.downcase == '.mp3' } # => ["./Music/The Snails - Red Rocket.mp3", #     "./Music/The Snails - Moonfall.mp3", #     "./Music/cancelled_download.MP3"]