Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.


share|improve this answer

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.

share|improve this answer
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 '13 at 11:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.