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.

3 Answers 3


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:


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



As you precisely describe, this is happening because it takes time to gather that information. If the operation times out before the system calculates the size, you'll get the error. When you use "Get Info" beforehand it caches the result.

  • I put that piece of code inside a try—end-try statement and that inside a repeat statement with many iterations, and it still didn't work. So it's not just a matter of giving the system time to obtain the information. I ended up using do shell script "du -ms " & quoted form of (POSIX path of thefile) & " | cut -f 1"
    – hawk
    Mar 14, 2013 at 11:56

I had exactly the same problem and solved it by getting size of all the files inside the folder:

set theSize to 0
set fileList to every item of folder x
repeat with theFile in fileList
    set theSize to theSize + (get size of theFile)
end repeat

Sometimes it results slightly different to what is shown in the folder properties but in general it's much better than size of folder x.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .