files = [ ]
Dir.glob( 'C:/Users/Owner/Documents/**/*.txt' ) do | full_path |
next if File.directory? full_path # ファイルだけを処理する
files.push full_path
end
puts files
Ruby なんて、これだけ。
glob に、** で再帰する。glob star
ただし、. で始まる、directory, file を除く
Dir.glob( 'C:/Users/Owner/Documents/**/*.txt' ) do | full_path |
next if File.directory? full_path # ファイルだけを処理する
files.push full_path
end
puts files
Ruby なんて、これだけ。
glob に、** で再帰する。glob star
ただし、. で始まる、directory, file を除く