leopard grinding to a halt on finder selection call

Hi,

I searched the archives for something on this, and couldn’t turn up anything so here goes:

I want to quickly find out wether there is a multiple selection happening in the finder and if so, bail out. This is because i want my script to mutilate a single file only, not any longer selection of files in the finder.

Now, if In the Tiger Finder I make a multiple selection of 600 files and then run:

tell application "Finder"
	count of (selection as list)
end tell

I get ‘600’ back in less than .1 second. Wonderful. for any practical selection length in the finder i get back a result quickly.

If I do this in Leopard however, the Finder just locks up for 14 seconds, spinning a beach ball.
My script can go on after some time-out, but in the mean time the Finder is still trying to come up with the list.

A solution would be:
If I could interrupt that Leopard Finder action in any way, my script could just give up after half a second, conclude there must be a bigger selection than one, and bail out. But i’d have to be able to tell the finder to not bother getting me the number anymore to get it out of its misery.

Any other ideas ?

I really hope one of you can help. I lost a day already trying to come up with a fix.

Arjen

Hi

selection is always a list, the coercion as list is useless.
Try this

tell application "Finder"
	count (get selection)
end tell

Whoa, quick answer stefan !

However, the problem is in the time it takes the Leopard finder to come up with ‘selection’ in the first place. Your solution does not change that.
Your (and my) solution on 250 files takes the finder 2.5 seconds to complete. A thousand files and we are down minutes.

Again: this was quick in Tiger, and incredibly slow in Leopard.

But thanks,

Arjen

I guess the story goes further. a Finder selections of over 300 files can hardly longer be queried:

from another thread i got this:

tell application "finder"
open disk "student" -->disk "student" contains about 1,000 folders
end tell

Under Tiger (10.4.9), The script runs, Finder pops up a window within seconds. Under Leopard (10.5.1), Finder goes unresponsive for 5 full minutes.

I guess this is the same as i am experiencing:

tell application "Finder"
	get selection
end tell

With hundreds of files selected this just locks up Leopards Finder, while all systems I remember before it have functioned wonderful.

As Stefan pointed out in the upper thread, ‘open disk’ was not necessary and could be avoided altogether by going to the UNIX command line.
But for ‘selection’ in the finder there is no alternative. On to apple for a problem report ?
Or is there some standard way of interrupting the current Finder action so it can be taken out of its lengthy action ?

Arjen