Skip to main content
added 1 characters in body
Source Link
Sjoerd C. de Vries
  • 66.1k
  • 15
  • 189
  • 327

Here is a version that passes Directory[] to df so you know how much space there is in MathematicasMathematica's current working directory.

I have tried it on linuxLinux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can do similarly with @WReach's solution, which would be better since it will work on all systems.

JavaBlock[JavaNew["java.io.File", Directory[]]@getFreeSpace[]]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can do similarly with @WReach's solution, which would be better since it will work on all systems.

JavaBlock[JavaNew["java.io.File", Directory[]]@getFreeSpace[]]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematica's current working directory.

I have tried it on Linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can do similarly with @WReach's solution, which would be better since it will work on all systems.

JavaBlock[JavaNew["java.io.File", Directory[]]@getFreeSpace[]]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on
added 2 characters in body
Source Link
ssch
  • 16.7k
  • 2
  • 54
  • 90

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can do similarly with @WReach's solution, which would be better since it will work on all systems.

JavaBlock[JavaNew["java.io.File", Directory[]]@getFreeSpace[]]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can do similarly with @WReach's solution, which would be better since it will work on all systems.

JavaBlock[JavaNew["java.io.File", Directory[]]@getFreeSpace[]]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on
added 2 characters in body
Source Link
ssch
  • 16.7k
  • 2
  • 54
  • 90

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", Property"Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", Property -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on

Here is a version that passes Directory[] to df so you know how much space there is in Mathematicas current working directory.

I have tried it on linux but I see no reason it shouldn't work on OSX and other unixy systems that have df.

Options[freeSpace] = {"Path" :> Directory[], "Property" -> 4};
freeSpace[OptionsPattern[]] := 
 Module[{out = 
    ReadList["!df '" <> ToString[OptionValue["Path"]] <> "'"
     ,Word 
     ,RecordLists -> True]
    ,i ,val},
  val = out[[-1, OptionValue["Property"]]];
  Quiet[Check[
    FromDigits[val],
    val, FromDigits::nlst
    ], FromDigits::nlst]
  ]

You can also check how much free space is on another disk, say you store your stuff elsewhere:

freeSpace[]                 (* 8898584 *)
freeSpace["Path"-> "/tmp"]  (* 20958736 *)

You can also extract other information that df gives:

freeSpace["Path" -> "/tmp", "Property" -> 1] (* "/dev/sda5" *)

The different properties are:

    1            2     3     4    5     6
Filesystem      Size  Used Avail Use% Mounted on
Source Link
ssch
  • 16.7k
  • 2
  • 54
  • 90
Loading