Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Reports remaining drive space for each specified drive (Windows)
require 'filesize'
require 'win32ole'
drive_list = ["D:", "H:"]
file_system ="Scripting.FileSystemObject")
drives = file_system.Drives
drives.each do |drive|
next unless drive_list.include? drive.Path
file ="#{drive.Path}//drive_status.txt", "w")
file.puts "Available space: #{Filesize.from("#{drive.AvailableSpace} B").to_s('GB')}"
file.print "Total size: #{Filesize.from("#{drive.TotalSize} B").to_s('GB')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.