Tell Finder

I have the below script that still runs in the AppleScript Editor, but fails in XCode:

set conversionFolder to (path to desktop as text) & "Test:"
tell application "Finder"
	set entireContents to (entire contents of folder conversionFolder)
	set fileList to (files of entireContents whose name ends with "txt") as list
	if (count of fileList) is greater than 0 then
		beep 2
	end if
end tell

Errors right on the first line “set entireContents to (entire contents of folder conversionFolder)”

Is using the FInder for this sort of thing not possible in ASOC? SHould I be using the NSFileManager for this sort of thing? Or shell scripts even?

Model: iMac
Browser: Firefox 3.6.4
Operating System: Mac OS X (10.6)

Never mind. I think I have it. Found a good example of NSFileManager in AppleScript ObjC Explored.

-- make it into NSString containing POSIX path so we can call method on it later 
set folderPath to current application's NSString's stringWithString_(POSIX path of convFolderAlias)

-- get default file manager 
set fileManager to current application's NSFileManager's defaultManager()

-- get array of entire contents
set allPaths to fileManager's subpathsOfDirectoryAtPath_error_(folderPath, missing value)

-- extract array of those with extension
set matchingPaths to allPaths's pathsMatchingExtensions_({"qxp", "qxd"})
set these_items to folderPath's stringsByAppendingPaths_(matchingPaths)
if (count of these_items) is greater than 0 then
	beep 2
end if

It’s entirely possible – just not a good choice. Even for standard AS, it’s becoming slower and flakier.