Get the names of all files in the directory. : Dir.reject « File Directory « Ruby






Get the names of all files in the directory.


d = Dir.open('mydir')
d.reject { |f| f[0] == '.' }

d.rewind
d.reject { |f| !File.file? File.join(d.path, f) }
d.close

 








Related examples in the same category

1.Get all contents other than ".", "..", and hidden files.