Hey Bert,
First and foremost never use Finder references unless you have a good reason to do so; they are painfully slow.
With a test sample of 500 files in Script Debugger with debugging [off]:
tell application "Finder"
set fl to target of front window as alias # Even this is faster when you coerce to alias.
set aliasList to files of fl as alias list # This is much faster than Finder References.
end tell
# ~ 0.75 seconds (as alias list)
# ~ 12 seconds (Finder References)
Peter is right too. Don't split up your operations unless you need to.
tell application "Finder"
set fl to target of front window as alias
set aliasList to files of fl as alias list
repeat with i in aliasList
set n to name of i
end repeat
end tell
# ~ 1.35 seconds (Repeat inside Finder-Tell)
tell application "Finder"
set fl to target of front window as alias
set aliasList to files of fl as alias list
end tell
repeat with i in aliasList
tell application "Finder"
set n to name of i
end tell
end repeat
# ~ 3.02 seconds (Repeat outside Finder-Tell)
-------------------------------------------------------------------------------------------
A fast non-Finder alternative:
-------------------------------------------------------------------------------------------
set fl to (path to home folder as text) & "test_directory:Many_Files:"
set fileList to do shell script "ls -1 " & quoted form of POSIX path of fl & " | sed -E 's/^/" & fl & "/'"
set fileList to paragraphs of fileList
repeat with i in fileList
set contents of i to (contents of i) as alias
end repeat
fileList
# ~ 0.15 seconds (for the same 500 files)
-------------------------------------------------------------------------------------------