Keyboard Maestro includes a For Each action category to loop over the Finder’s selection. Usually the performance was OK, but occasionally I'd see horrendous performance. I tracked it down to the speed of this simply AppleScript:
tell app "Finder" to get the selection
In some cases it would take seconds or even tens of seconds per item returned (this seemed particularly bad in my Trash folder which has thousands of items - selecting even a dozen files could mean the AppleScript took a minute to run!
I comments on Twitter, and Takaaki Naganoya responded on Twitter to try "selection as alias list".
Boy was he right. The response to this:
tell app "Finder" to get the selection as alias list
is near instantaneous, every time. You get a slightly different result format for the results, but in all likelihood you'll get functionally the same behaviour at vastly improved speeds.
These results were on my Mac running 10.7.4 so it may be wise to verify the issue across a wider range, but since I cannot see any downside, this is the code I'll use in Keyboard Maestro in the future.
Posted Friday, June 22, 2012. Permalink. Post a Comment.
None yet.
Comments