Re: Determing the Size of a File
Re: Determing the Size of a File
- Subject: Re: Determing the Size of a File
- From: Pier Kuipers <email@hidden>
- Date: Wed, 2 May 2001 23:10:33 +0100
>
Is there any possible routine I could use to display the size of a file in a
>
human readable form (For example 1.5 Megs etc.)
The simplest way would be something like this (run script after
selecting one file in the finder):
tell application "Finder"
set theFileSize to (((size of selection) div 100000) / 10) &
" MB" as text
end tell
return theFileSize --> "x MB"
Of course this is ignoring the fact that 1K is actually 1014 bytes or
something like that, so the figure is not 100% accurate. Another
consideration might be, if you read file sizes as bytes transmitted
in the log files of a web server. This will show a number equivalent
to the number of bytes in the Data fork of the file, having left out
the resource fork. The way to find out a file's data size only is to
open it for access and reading it till eof. You would use something
like:
tell application "Finder"
set theFile to selection
set theFileSize to ((((get eof (open for access theFile)) div
100000) / 10) & " MB" as text)
close access theFile
end tell
return theFileSize --> "x MB"
Hope this helps.
Pier.
--
Pier Kuipers
Visual ID
* the Media Asset Management solution *
2 Whitefriars
Aungier Street
Dublin 2
Tel. +353 1 476 7059
Mobile +353 87 294 3063
Fax +353 1 478 1366
ISDN +353 1 602 0754
http://www.visualid.com