Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get disk space of windows machine with R?

Tags:

windows

r

cmd

How can I get the total disk space / free disk space of my windows computer ?

If there is no R function, maybe there is a windows command that I could use within the R system function but I wasn't able to find that command.

like image 261
Julien Navarre Avatar asked Aug 25 '15 09:08

Julien Navarre


People also ask

How do I see total disk space on Windows?

From the Windows desktop, double-click the My Computer icon. In My Computer, highlight and right-click the drive whose capacity you'd like to determine. In the menu that appears, select Properties. The Properties window displays the used space, free space, and the total capacity of the hard drive or other drives.

How do I show disk space in CMD?

Search command prompt in Windows 10, and right-click on the result and choose Run as administrator. Step 2. Type wmic diskdrive get size and press Enter. Finally, the total size of hard disk space (in pure number) is displayed in the figure below.


1 Answers

Though I find it really difficult to believe that a Google search for windows cmd disk space came up empty for you, this should provide the information you need w/o the need for admin privileges:

disks <- system("wmic logicaldisk get size,freespace,caption", inter=TRUE)

disks <- read.fwf(textConnection(disks[1:(length(disks)-1)]), 
         widths=c(9, 13, 13), strip.white=TRUE, stringsAsFactors=FALSE)

colnames(disks) <- disks[1,]
disks <- disks[-1,]
rownames(disks) <- NULL

disks

##   Caption   FreeSpace        Size
## 1      A:                        
## 2      C: 52617023488 63898120192
## 3      D:                        

Just thought I'd also add that this answer comes from someone who is primarily an OS X/Linux user.

like image 88
hrbrmstr Avatar answered Sep 27 '22 17:09

hrbrmstr