Get names of all files from a folder with Ruby

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

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

19条回答
  •  旧时难觅i
    2020-11-29 15:53

    When loading all names of files in the operating directory you can use

    Dir.glob("*)

    This will return all files within the context that the application is running in (Note for Rails this is the top level directory of the application)

    You can do additional matching and recursive searching found here https://ruby-doc.org/core-2.7.1/Dir.html#method-c-glob

提交回复
热议问题