Skip to main content

I'm trying to calculate free space on Catalina. For prior versions of macOS, this piece from a script from Joshua Roskos' macOS Upgrade script works:

diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
    ## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
    freeSpace=$(
    /usr/libexec/PlistBuddy -c "Print :FreeSpace" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :AvailableSpace" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
    )

But on Catalina, the result is "0" every time. The FreeSpace key that is generated by:

/usr/sbin/diskutil info -plist /

is always "0" on Catalina. What needs to be changed to get the correct value for FreeSpace?

Hi I use....

df -m /Volumes/Macintosh HD | awk '{print $4}' | grep -v "Available"

And it shows the number of Mb available, divide by 1024 to get Gb


Hi I use....

df -m /Volumes/Macintosh HD | awk '{print $4}' | grep -v "Available"

And it shows the number of Mb available, divide by 1024 to get Gb


This is interesting and helfpful @PaulHazelden  — Is this able to be used in Big Sur as well as Catalina as an extension attribute with as an Integer? 


This is interesting and helfpful @PaulHazelden  — Is this able to be used in Big Sur as well as Catalina as an extension attribute with as an Integer? 


Yes the code works in Big Sur, it is Bash. You would need to set it up to publish its results to make it into an EA.

I use it to report space to the user with a notification popup. Our Macs get a lot of the user space cleared out every day, but some of the students working on Movies can get a bit carried away and drop a serious amount of files on the hard drive. So they get warnings.