Need Help on "Repeat With" script

So I’m writing a script to analyze a folder filled with files. Do a process and pull information about each file. The script works perfectly except when there is only 1 file in the folder i’m analyzing. Because my processing is all done inside of the repeats, when there is only 1 file available it skips over the repeat. It’s seems like a really simple fix, but I am stumped…

Here is my script simplified for troubleshooting.

--> Usually run this script as a folder action, but simplified for this purpose I'm trying to troubleshoot my repeat line.
set added_items to choose folder
--> Typically my input will be a folder with anywhere from 1 to 100 files in it.

tell application "Finder"
	set file_list to every file of entire contents of added_items
	-->This is where it breaks down.  If there are multiple files in the folder it runs perfectly.  It there is only one file in the folder then it skips over the repeat.
	repeat with every_item in file_list
		--> Analyze each file in the folder, pull information, and do some other processing.
		display dialog (name of every_item as text)
	end repeat
	display dialog "- End Of Script -"
end tell

Any help would be much appreciated. Thanks!

Try adding set set file_list to file_list as list right before the repeat loop. Or use if class of file_list is not list then set file_list to {file_list} if you prefer a less “magical” incantation.

The problem is that when there is only one item to return, Finder returns the single item instead of a list that holds only the single item. It “feels” like a bug to me, but I assume it is just some long-standing backwards-compatible “feature” that must be maintained due to the original AppleScript-able Finder doing it that way.

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 4.0.3 (4531.9)
Operating System: Mac OS X (10.4)

Awesome! They both work perfectly. I’ll plug it into my larger script and see how it does.

Thanks so much.