Skip to content

Instantly share code, notes, and snippets.

@electronicbites
Created February 8, 2011 18:46
Show Gist options
  • Save electronicbites/816958 to your computer and use it in GitHub Desktop.
Save electronicbites/816958 to your computer and use it in GitHub Desktop.
scan a directory for audio files
def dir_scan(src, files = [])
Dir.foreach(src) do |e|
# Don't bother with . and ..
next if [".",".."].include? e
fullname = src + "/" + e
if FileTest::directory?(fullname)
files = dir_scan(fullname, files)
else
if (e.match("(.)m4a") || e.match("(.)aac") || e.match("(.)mp3"))
files << fullname
else
puts "unkown format: #{fullname}"
end
end
end
files
end
files = dir_scan src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment