I cannot duplicate the error message you are describing. I get an error message like this (sometimes the error number is #3)
- filesize(“/Users/jimrea/Documents”) The operation couldn’t be completed. (Cocoa error 2.)
Your workaround uses a feature of the ls shell command that I wasn’t aware of, that the # of blocks is displayed on the first line of the generated output, like this:
-rw-r--r-- 1 jimrea staff 2423 Aug 25 14:33 data.archive
-rw-r--r-- 1 jimrea staff 2269 Aug 25 14:33 data.plist
-rw-r--r-- 1 jimrea staff 4454 Aug 25 14:33 fieldconfig.archive
-rw-r--r-- 1 jimrea staff 236 Aug 25 14:33 forms.archive
-rw-r--r-- 1 jimrea staff 644 Aug 25 14:33 printinfo.archive
-rw-r--r-- 1 jimrea staff 9235 Aug 25 14:33 procedures.archive
-rw-r--r-- 1 jimrea staff 233 Aug 25 14:33 settings.plist
-rw-r--r-- 1 jimrea staff 367 Aug 25 14:33 variables.archive
If the folder contains a file name that contains “total” within the name, using tagarray( could calculate the wrong value. I thing using tagdata( would be better. I’ve spread the formula out over multiple lines to make it more readable.
"ls -l "+unixshellstring(path)),
However, in my tests I found that the output of the ls shell command isn’t reliable, or at least it doesn’t always agree with the Finder’s Get Info window. When I tried to use it on my Documents folder it was way off, nearly an order of magnitude. I don’t know if the problem is in ls, or in Get Info, or both. I did verify that the calculation manually using the terminal output, so I know that ls is the problem and not the Panorama code.
Another question would be “what is this number good for?” It’s not the actual amount of data in the file, which is generally much smaller. You could theoretically calculate that from the ls output, though that would be quite a bit more complicated, and could be quite slow if a folder contains hundreds or thousands of files (don’t forget that folders can be nested within folders within folders).
Still, Gary’s solution is quite clever – bravo for noticing that ls has this feature.