Get free disk space under windows with dir command : Utilities « File Directory « Ruby






Get free disk space under windows with dir command


def freespace(device=".")
  lines = %x(cmd /c dir #{device}).split("\n")
  n = lines.last.split[2].delete(",").to_i
end

puts freespace "C:"       

 








Related examples in the same category

1.delete a folder recursively
2.Find files
3.Delete with condition
4.Get free disk space under unix with df command
5.Call system function to delete a folder
6.Showing Line Numbers
7.Delete folder older than a certain time
8.Parse line: value|value
9.Change a | delimited file