Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Created October 30, 2014 10:00
Show Gist options
  • Save campanalbero/14cda6ace0e3719e701f to your computer and use it in GitHub Desktop.
Save campanalbero/14cda6ace0e3719e701f to your computer and use it in GitHub Desktop.
引数で指定するフォルダ以下のファイルの拡張子毎にパスを出力する
hash = Hash.new()
Dir.glob(File.expand_path(ARGV[0]) + '/**/*') do |f|
if File.ftype(f) == "file"
ext = File.extname(f)
arr = hash[ext]
if arr == nil
arr = Array.new()
end
hash.store(ext, arr.push(f))
end
end
hash.each do |key, value|
puts ""
puts key
value.each do |item|
puts item
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment