On Apr 7, 2010, at 6:41 AM, Axel Luttgens wrote: It often appears that you insist on asking applications to build AppleScript lists when not really needed.
If you want the Finder to count disk items, just ask the one who knows, that is the Finder:
Yes, but the point of the scripts was to test how fast Finder, System Events and 'ls' could build a list.
The line ...
set itemCount to (count files of entire contents of folder folderAlias)
does work fairly quickly. However the following test script ...
on open dropList if (count items of dropList) > 1 then return set folderAlias to (item 1 of dropList) as alias tell application "Finder" to if (class of item folderAlias) is not folder then return set elapsedTime to (current date) -- date (date string of (current date)) set cutoffTime to ((the result) - (15 * days)) tell application "Finder" if (exists (some document file of entire contents of folderAlias whose modification date < cutoffTime)) then set itemExists to true else set itemExists to false end if end tell -- set elapsedTime to ((current date) - elapsedTime) "item = " & itemExists & return & "time = " & elapsedTime & " sec" display dialog the result buttons {"OK"} default button 1 end open
Takes 7 sec with the 532 item folder used in the previous tests (which has no sub-folders) and 8 seconds on a folder containing 286 files distributed among 52 sub-folders. This is way too slow.
I was using the 'exists ...' line in an application where it was intended to speedup the action, but it had the opposite effect and I had to remove it. It was quicker just to scan all sub-folders.
|