I'm trying do some operations on a directory which contains nearly 20 million files, I tried Dir.glob
, Dir.foreach
and Dir.entries
to no success.
Is there anything similar to Csharp's Directory.EnumerateFiles
in ruby which can enumerate a huge list of files?
Asked
Active
Viewed 58 times
0

Jeremy Mc
- 119
- 1
- 10
-
2_"... to no success"_ – please be more specific. What happens and how do you use these methods? (i.e. show some code) – Stefan Oct 04 '16 at 12:10
1 Answers
0
Dir#read might do the trick.
dir = Dir.new(path)
while entry = dir.read
puts entry
end

Kimmo Lehto
- 5,910
- 1
- 23
- 32
-
Thanks for your answer, But sadly it didn't do it either. Like other ones I tested, just hangs for a veeery long time and nothing happens. – Jeremy Mc Oct 04 '16 at 10:36
-
@JeremyMc it's probably working just taking a long time. isn't it printing the entry for you? – Tiago Lopo Oct 04 '16 at 11:24
-