Inconsistent results when getting folder size in AppleScript

I'm using this line to get the size of a folder:

set thesize to physical size of folder x

The problem is that sometimes it works, other times it doesn't, and it's very annoying because there doesn't seem to be any kind of logic to it. The same folder path can return "missing value" at first, then return the number of bytes later, without any code change. It seems to start working more often after I "Get Info" on the folder in the Finder, but even that doesn't always work.

How do you make this reliable? I can't send my application to other people with this kind of unpredictability on my own computer.


Try Automator. I did it and it worked for me on each folder. I tried it as a Service.

I might have automator actions that you don't have.

You can get them here if that's the case:

http://www.automatedworkflows.com

There you will find awesome automator action packs. Very useful.

Phil