[Pythonmac-SIG] os.path.getsize()

John W Baxter jwblist@olympus.net
Thu, 2 Mar 2000 23:03:40 -0800


At 18:19 +0100 2/29/00, JoanCarles p Casas=EDn wrote:
>Note that all these methods give you the number of bytes in the file,
>*not* the amount of space it occupies on disk (the finder info command
>gives both). Does anyone know how to obtain the diskspace numbers?

One way is to ask the Finder for the "physical size" property of the file.
In AppleScript, that's
tell application "Finder"
	physical size of file "play" of desktop
end tell
result as integer

Despite what the Finder's dictionary says, it now (in Mac OS 8.6 anyhow...9
isn't handy at this moment) returns a floating point value (the result of
Mac OS understanding large files).  Hence the as integer (which you can
stick after the of desktop <or whatever the location is> if desired).  (How
do I round an arbitrary float to a Python long integer...probably the right
form to use.)

  --John (stating the obvious:  platform-specific)
-- 
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA