I know a workaround, where one calculates sizes of all files and then you subtract this from your default space, but is there any direct way to do it? Simplicity and speed are important.
There's the way to calculate free RAM with external call
ReadList["!typeperf \"\\Memory\\Available Bytes\" -sc 1", Word,
RecordLists -> True, WordSeparators -> {","}] //
ToExpression@Part[#, 2, 2] &
Is there any way to do the same but for disk space?
SOLVED
StringJoin[
ReadList["!dir c:\ ", Word, RecordLists -> True,
WordSeparators -> {" ", ","}][[-1, 3 ;; -3]]] // ToExpression
gives the amount of free memory on disk C in bytes)
dir
gives this information in its output. $\endgroup$Select[ ReadList["!df", Word, RecordLists -> True, WordSeparators -> {",", " "}], First@# == "/dev/disk1" & ]
should do the trick (on OSX and I guess linux) $\endgroup$\LogicalDisk(*)\Free Megabytes
, so you can usetypeperf
to get the information if you like. However, this only works if your user account has the "profile system performance" privilege assigned. By default this is only granted to Administrators! $\endgroup$df
call, I'd display all disks:TableForm[Transpose[{##2}], TableHeadings -> {#, Automatic}] & @@ ReadList["!df -l -k", Word, RecordLists -> True, WordSeparators -> {",", " "}]
$\endgroup$