Testing if selected item is an application

I’m writing an Automator action that tests if the selected item is an application and if it is it does something else returns an error message. How do I test to see if the selected item is an application? Thanks!

Hi Hendo,

in the Finder the class of applications is application file


tell application "Finder"
	set sel to selection
	repeat with oneFile in sel
		if class of oneFile is application file then say name of oneFile & " is application"
	end repeat
end tell

Ah great, thank you, I saw the application file but didn’t know how to refer it (aka class).
How would I go about about testing the same thing but in the applications folder?

If you mean is the app chosen in the Applications Folder, then parse its path:

if ((choose file) as text) contains "Applications" then
	display dialog "It's in the folder"
else
	display dialog "Oops -- not in /Applications"
end if