I share your sentiments on AppleScript, but fortunately many operations done with it can also be done with fewer layers using shell commands. Whenever you can find a shell equivalent you should be able to call it with the shell function in LiveCode and enjoy both simpler syntax and faster execution.
For file sizes in folders and volumes you can use "du" ("Disk Usage"). See "man du" in Terminal for details, or better yet check out this page which has additional notes:
http://ss64.com/osx/du.html
You can call this from within LiveCode with:
Code: Select all
put shell("du -sk <path>") into tVar
The "s" flag tells du to list only the specified file or folder, and the "k" flag tells it to use a recursive total for the folder's contents. "<path>" is of course where your path would go, e.g.:
Code: Select all
put shell("du -sk /Users/rg/Downloads") into tVar
The resulting value will be a return-delimited list in which each line gives the size of each path supplied to it and the path itself, e.g.:
556116 /Users/rg/Downloads
Getting word 1 of the value returned from your shell call will give you the total kb for the path supplied.
Since the path may contain space characters, it's probably a good idea to put the path in quotes:
Code: Select all
answer folder "Select a folder:"
put it into tDir
put shell("du -sk ""e&tDir"e) into tVar
put word 1 of tVar into tSize
Note that the value returned is the physical size, not the logical size, so it may appear slightly smaller than the value you see in the Finder's Get Info window. Physical size totals only the bytes actually used in the files, but logical size is the sum of the allocated space; on most OS X systems the smallest allocation block is 4k, so a file that has only 1k of data will be shown as a 4k file in Get Info, but as a 1k file with du.