Get names of all files from a folder with Ruby

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

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

19条回答
  •  清酒与你
    2020-11-29 15:35

    Personally, I found this the most useful for looping over files in a folder, forward looking safety:

    Dir['/etc/path/*'].each do |file_name|
      next if File.directory? file_name 
    end
    

提交回复
热议问题