Drive Used Space to Variable

Hello, I'm using an applescript to get drive space used, and it works on certain drives, but doesn't seem to work on APFS volumes. It gives back no data and clears whatever previous variable value was there. Any suggestions on either a fix or a better way to get the used space, regardless of of filesystem?

DriveSpace_to_variable.kmmacros (2.5 KB)

Go via the Finder instead. For example:

tell application "Finder"
	return (size of disk "Macintosh HD") / 1000 / 1000 / 1000
end tell

Thanks, that works if I specify the specific drive. I'll work on feeding it a variable from KM as the source drive will vary each time.

How you do that will depend on what you are passing from KM. Volume name is easiest, but the "Choose folder" action in your sample will provide a POSIX path (I think), in which case this should work (using your variable name):

set kmInst to system attribute "KMINSTANCE"

tell application "Keyboard Maestro Engine"
	set itemPath to getvariable "Backup1DIR" instance kmInst
end tell

tell application "Finder"
	(size of ((POSIX file itemPath) as alias)) / 1000 / 1000 / 1000
end tell

That's perfect! Thanks for the guidance.