List Files of Chosen Folder

This AScript works in OS9. Now in OSX I get the following error message: “Finder got an error: Unknown object type.”

This script originally came from “Sal’s AppleScript Snippets” at (Thanks Sal!)

What is going on, and how do I fix it? This was a very helpful script because OSX got rid of the Print Window command.

tell application "Finder"
   set theFolder to choose folder
   set theList to (every file of theFolder) as list
   set theList to (sort theList by name) as list
   set defaultNameList to "Every file of folder: " & (name of theFolder)
   set theNameList to defaultNameList
   repeat with thisItem in theList
      set theNameList to theNameList & return & name of thisItem
   end repeat
end tell

if theNameList is defaultNameList then
   display dialog "No files found." buttons {"Cancel"} default button 1
end if

   set the clipboard to theNameList
   beep 2
on error
end try

Thanks in advance for your consideration.

This should do what you want (full paths with recursion):

Or just item names of the root level of the chosen folder:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

THANKS! That was exactly what I was looking for!

Your help is greatly appreciated.

–Herbert Ripka
Reiman Publications
Greendale, WI