Display amount of disk available for use

Simple challenge

I have a MacBook with 500gb ssd disk

I would like a simple KM Macro to run at login to advise me / display msg

A: of current amount of disk free e.g. 120 gb xx% available

B : and slightly more strongly if I have less than 100gb free.

Any ideas?

My recommendation is that instead of a warning at login you simply have an item placed into the status bar on the top of your screen that updates every minute, saying how much space you have. That way you always have the free space value easily visible. I'm going for lunch now so I can't write that for you for a while.

Good idea. Here's my take on it:

Free Space.kmmacros (5.4 KB)

2 Likes

Usual caveats about Apple's wacky disk space reporting apply -- for example, df's "Available Space" doesn't include purgeable -- so don't be surprised when every method you use gives you a different answer!

That said, I like @Evan_Mangiamele's above because it is conservative, using powers of 1024 rather than 1000 and considering purgeable space to be unavailable. Much better to under- rather than over-estimate your available elbow-room.

1 Like

I spent the whole day working on an interesting solution. My solution is large enough to merit its own post on another thread on this site. I'll post it in about 2 minutes.

Since I'm learning a little sed, here is my offering.

Available Disk Space.kmmacros (11.4 KB)

Macro Image

KC

1 Like

Thanks for both solutions.
I have selected Evan_Mangiamele 's although it was a close call between them.
I have modded it to a "silent" version that is now included with a cron job I run every 15 minutes. Silent i.e. only notify me if running out of disk space.

1 Like

For a further herculean effort by Airy to solve this, see also

I have extensively amended the handling of Evan's solution. It has two parts
a: initialising of displayed message count
b: the actual macro which will display a prompt if you are running out of disk space.
Note: So that you are not overwhelmed by warning messages
a: messages 4,3,2 are suppressed, 1 will cause prompt
b: the prompts have a timeout delay

Implementation
a: Choose how often you want the test to run e.g. every 15 mins
b: To choose your percentage free space e.g. 20%

Bonus: Simple macro to Open/Switch to KM Engine log


JGLp [DiskFreeSpaceCheck] Macros 2 04g .kmmacros (26.4 KB)

Nice!

I always find it interesting to look through other's macros.

Something you do in here, which I'm going to steal for my own macros, is saving of an example string in a comment action prior to a search with regular expression.