Long delay to open file selection dialog with choose folder

I am developing a control dialog, using Satimage’s Smile dialog functionality. The task is pretty simple: having the user select a folder whose contents then will be copied to the in-folder of a workflow. To accomplish that, I use the following code:

set myPath to "/tests/sampling_folder/"
set targetFolder to POSIX file myPath as alias
tell application "Finder" to copy files of folder (choose folder with prompt "Zu übertragendes Verzeichnis wählen") to folder targetFolder

When I run it on my system (MacBook Pro (2008), OSX 10.6.8) with no mounted network drives or external disks, the folder picking dialog opens quite quickly. When my client tries it on his machine (iMac, OSX 10.8) with one or two network drives mounted, it may take a rather long time (up to about a minute or so) until the dialog shows up.

Are there any known issues with this environment which can explain the effect? Or am I doing something not quite right (being still a noob with Applescript)?

Thanks a lot in advance.

Max Wyss.

Choose folder is a function from the OSAX Standard Additions.

When you call it in a tell finder block, your case, you get :

tell application “Finder”
choose folder
→ error number -1708
«event ascrgdut»
→ error number -1708
choose folder
→ alias “Macintosh HD:Users:yvankoenig:Desktop:642f8e1acaf6ee783aec6840370f6f29065dbcc55df2e2d92e09bdcd5a50f003:”

This behaviour is described in a recent AppleScript Release Notes document.

You will retrieve your “old” behaviour if you code :

tell me to choose folder
tell application “Finder” to copy files of result .

which would execute this way:

tell application “AppleScript Editor”
choose folder
→ alias “Macintosh HD:Users:yvankoenig:Calibre Library:”
end tell
tell application “Finder”
.

As you see, choose folder is executed in a single call which explain the execution time difference.

KOENIG Yvan (VALLAURIS, France) jeudi 19 septembre 2013 18:05:07

I had a similar issue. I switched from making Finder calls to doing shell scripts (see below). Problem solved.

on getMagDirs(gMag)
	
	set magDirs to {} as list
	set volList to (do shell script "ls /Volumes")
	set diskList to {}
	repeat with thisParagraph in every paragraph of volList
		set end of diskList to thisParagraph
	end repeat
	
	repeat with i in diskList -- possibly report reduced performance when "format:AppleShare format" is detected.
		
		set targetFolder to ((i as text) & ":" & (gMag as text))
		if getFolder(targetFolder) is true then set magDirs to magDirs & (targetFolder as alias)
		
		set targetFolder to ((i as text) & ":" & (gMag as text) & " Archive")
		if getFolder(targetFolder) is true then set magDirs to magDirs & (targetFolder as alias)
		
	end repeat
	return magDirs
end getMagDirs

actually off topic, but the proper command to “copy” file in the Finder dictionary is duplicate