ASTONISHING RESULTS + erratum & addendum (Calculate sizes script)
ASTONISHING RESULTS + erratum & addendum (Calculate sizes script)
- Subject: ASTONISHING RESULTS + erratum & addendum (Calculate sizes script)
- From: Mr Tea <email@hidden>
- Date: Fri, 08 Feb 2002 23:10:14 +0000
First, the erratum.
A script for writing the size of finder items into their comments boxes that
I posted here ("Size with AS vs Size displayed in Finder: Why different?")
generates an error if it encounters an empty folder.
So, in the unlikely event that anyone might want to use the script, an
amended version that deals with this issue is reproduced below. It's written
as a droplet designed to have a single folder (or disk/volume) dropped onto
it. It will write each item's size into its 'get info' comments field at the
top level of the dropped folder. This is information that I find useful when
figuring out what else I can cram onto a backup CD-ROM or similar.
My stated reason for writing this script was that it returns folder sizes
faster than the Finder's 'calculate folder sizes' view option ('calculate
all sizes' in OS X). I did some comparative tests to make sure that I wasn't
blowing hot air, and was AMAZED by the results. Particularly when I made the
same comparisons in OS X. Here's what I found...
Test 1: [5 GB volume; 2.97 GB used; 15,110 items; 6 top-level folders]
OS 9 Finder... 33 seconds
OS 9 AppleScript... 2 seconds (lookin' good!)
(not tested in X)
Test 2: [20 GB volume; 6.11 GB used; 19,574 items; 14 top-level folders]
OS 9 Finder... 79 seconds
OS 9 AppleScript ... 4 seconds (now we're cookin' - eat dust, Finder!)
OS X Finder... 4 seconds (whooo!)
OS X AppleScript ... 1 second (ahh!)
Test 3: [8.26 GB volume; 4.75 GB used; 106,572 items; 11 top-level folders]
OS 9 Finder ... 101 seconds
OS 9 AppleScript... 137 seconds (whoops! )
OS X Finder ... 25 seconds
OS X AppleScript... 15 seconds (yay! go, go, go, applescript!)
Looks like the Applescript droplet running in OS 9 choked somewhat on all
those thousands of tiny, unfamiliar files in my OS X system folder during
the third test, but all the other figures add up to a pretty good showing
for AS. And, indeed, for OS X.
This is the first time I've experienced tangible evidence of the superiority
of X - and it's pretty darned convincing.
Now, before I forget, here's that script (so y'all can do your own speed
tests).
on open {theFolder}
tell application "Finder"
activate
set theItems to every item of theFolder as alias list
end tell
repeat with anItem in theItems
if size of (info for anItem) > 0 then
copy (size of (info for anItem)) / 1.073741824E+9 to theGBs
if theGBs < 1 then
set theMBs to theGBs * 1024
if theMBs < 1 then
set theKBs to theMBs * 1024
set theComment to text 1 thru ((offset of "." in theKBs
as string) + 2) of (theKBs as string) & " KB"
else
set theComment to text 1 thru ((offset of "." in theMBs
as string) + 2) of (theMBs as string) & " MB"
end if
else
set theComment to text 1 thru ((offset of "." in theGBs as
string) + 2) of (theGBs as string) & " GB"
end if
else
set theComment to "0.00"
end if
tell application "Finder" to set comment of anItem to theComment
end repeat
end open
(Any line that abuts the left margin and doesn't begin 'on' or 'end' has
been wrapped & should be appended to the previous line.)
Mr Tea
--
Brew of the day: China Yunnan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.