HiveBrain v1.2.0
Get Started
← Back to all entries
patternrubyCritical

Get names of all files from a folder with Ruby

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
withfromfilesrubyfolderallgetnames

Problem

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

Solution

You also have the shortcut option of

Dir["/path/to/search/*"]


and if you want to find all Ruby files in any folder or sub-folder:

Dir["/path/to/search/**/*.rb"]

Code Snippets

Dir["/path/to/search/*"]
Dir["/path/to/search/**/*.rb"]

Context

Stack Overflow Q#1755665, score: 638

Revisions (0)

No revisions yet.