Q:

How do I get a listing of only files using Dir.glob?

How can I return a list of only the files, not directories, in a specified directory?
I have my_list = Dir.glob(script_path.join("*"))
This returns everything in the directory,including subdirectories. I searched but haven't been able to find the answer.

A:

In addition to Mark's answer, Dir.entries will give back directories. If you just want the files, you can test each entry to see if it's a file or a directory, by using file?.
Dir.entries('/home/theiv').select { |f| File.file?(f) }

Replace /home/theiv with whatever directory you want to look for files in.
Also, have a look at File. It provides a bunch of tests and properties you can retrieve about files.

A:

Dir.glob('*').select { |fn| File.file?(fn) }

A:

Entries don't do rescursion i think. If you want the files in the subdirs also use
puts Dir['**/*'].select { |f| File.file?(f) }

