Created
February 8, 2011 18:46
-
-
Save electronicbites/816958 to your computer and use it in GitHub Desktop.
scan a directory for audio files
This file contains hidden or 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
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