Get names of all files from a folder with Ruby

后端 未结 19 2370
[愿得一人]
[愿得一人] 2020-11-29 14:57

I want to get all file names from a folder using Ruby.

19条回答
  •  隐瞒了意图╮
    2020-11-29 15:41

    One simple way could be:

    dir = './' # desired directory
    files = Dir.glob(File.join(dir, '**', '*')).select{|file| File.file?(file)}
    
    files.each do |f|
        puts f
    end
    

提交回复
热议问题