The StandardAdditions command 'list folder' is deemed deprecated, and Apple says one should use System Events instead. However, on a folder with many items, that is really a bad recommendation, as is shown below: Example folder has 3794 visible files. The deprecated command 'list folder' needs to have an 'alias' or 'file' after it in order to avoid bugs, like this: list folder file theFolderPath without invisibles Timing this gets me between 90 and 149 ms.
The System Events version, but including invisibles, is: tell application "System Events" to get name of files in folder theFolderPath Timing this gets me between 490 and 780 ms! Pretty unacceptable slowdown by itself, but it does not even do what we want!
It really should be as follows: tell application "System Events" to get name of files in folder theFolderPath whose visible is true
However, that will timeout and crash System Events!!
By far the best alternative is to use the Unix 'ls' in a do shell script, thus: paragraphs of (do shell script "ls " & quoted form of POSIX path of theFolderPath) Timing this gets me between 42 and 46 ms! I.e even better than the old 'list folder'!
On Leopard and Tiger, it also works for files with "funny names" (non ascii). (But 'ls' will also list an "invisible" Icon-file if it exists, but that is no big deal.)
The reason I needed to investigate this is that I was dumb enough to simply replace a 'list folder' I had in a product I sell, with the "corresponding" System Events surrogate. I only tested that it worked, but didn't realize it was going to crash if the number of files is large.
/h
______heb____________________________
|