J
Jesús Gabriel y Galán
Hi,
I have a list of files and I need to produce a string containing the
size of each file, but in human readable format. With that I mean
something like what df -h does: make an approximation to the nearest
unit (B, KB, MB, GB, etc). Is this already done somewhere? This is
what I have now:
Find.find(folder) do |file|
match = regexp.match(File.basename(file));
if match
size = File.stat(file).size
puts size # would like a human readable format
end
end
Thanks,
Jesus.
I have a list of files and I need to produce a string containing the
size of each file, but in human readable format. With that I mean
something like what df -h does: make an approximation to the nearest
unit (B, KB, MB, GB, etc). Is this already done somewhere? This is
what I have now:
Find.find(folder) do |file|
match = regexp.match(File.basename(file));
if match
size = File.stat(file).size
puts size # would like a human readable format
end
end
Thanks,
Jesus.