But maybe I'm missing something. So let's say you're using entire contents -- can you show some code for how you intend to take that list of aliases or paths and format it something like Alex suggested?
Actually looking at the output of theNSFileManager's subpathsAtPath:"/Users/shane" not just it was significantly faster than entire contents but the output is better to work with.
In any case, when I tried to run theNSFileManager's subpathsAtPath: “/Applications” it stalled ASE.
subpathsAtPath: is not a good choice because it's going to list everything inside every app bundle, and there are going to be zillions in /Applications. A better way is to use enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:. It's a bit more complex to use, but it lets you specify two important options: to skip invisible files, and to skip recursing into packages. The latter not only eliminates stuff you don't want, but it also speeds it up in this case massively. This takes about a second on my Mac for 57153 items:
use scripting additions
use framework "Foundation"
set thePath to POSIX path of (path to applications folder)
-- make NSURL
set anNSURL to current application's |NSURL|'s fileURLWithPath:thePath
-- get file manager
set theNSFileManager to current application's NSFileManager's defaultManager()
-- define options to use
set enumerationOptions to ((current application's NSDirectoryEnumerationSkipsPackageDescendants) + (current application's NSDirectoryEnumerationSkipsHiddenFiles as integer))
-- get enumerator
set theEnumerator to theNSFileManager's enumeratorAtURL:anNSURL includingPropertiesForKeys:{} options:enumerationOptions errorHandler:(missing value)
-- ask enumerator for all its files, and use valueForKey: to turn NSURLs into paths
set thePaths to (theEnumerator's allObjects()'s valueForKey:"path") as list
But again, formatting the results as Alex wanted still seems a fair bit of work. (And in passing he mentioned OS X 10.8.)
Now for what I believe it is a bug
The original script posted
<script>
tell application "Finder"
set currentDir to (target of front window)
set CDir to currentDir as alias
set allFiles to (entire contents of CDir) as alias list
return (allFiles)
end tell
</script>
works fine. Now lets say that the target of the front window is my documents folder, this times out
<script>
tell application “Finder"
set allFiles to (entire contents of folder “HD:Users:deivy:Documents:”
end tell
</script>
Both pointing to the same folder.
It's not a bug so much as that getting Finder references takes a lot longer than getting a list of aliases. Actually, *getting* the information is not the problem -- it's building those Finder references to return that takes the time. Each of those "... of folder ..." bits has to be built separately, and that all adds up.