Info for command

Dear,

I a’m trying to get info to check if a selected item is a folder or a file
but i get an error and i dont seem to find the right syntax for it.
does anyone have a solution

the script:

tell application “Finder”
activate
set selectedFolder to (choose folder)
set selectedFoldername to name of selectedFolder
–return selectedFoldername & " - " & selectedFolder

set info_for to info for selectedFolder
if folder of info_for is true and package folder of info_for is false then
	display dialog "It's a folder"
else
	display dialog "It's a file or package."
end if

end tell

the error
Can’t get folder of …[/b][b]

For starters, you don’t need to use the Finder for this. Besides taking the Finder out of the script, I’ve made a couple of small changes which should yield the proper result. It works on my system (10.2.2). :slight_smile:

set selectedFolder to (choose folder)
--set selectedFolder to (choose file)
--return selectedFoldername & " - " & selectedFolder 

set info_for to info for selectedFolder
set selectedFoldername to name of info_for

if folder of info_for is true and package folder of info_for is false then
	display dialog "It's a folder"
else
	display dialog "It's a file or package."
end if

I’d use Finder for this; it’s faster and a bit more backwards-compatible than ‘info for’. (Note that Finder recognises application packages as application files.)

tell application "Finder" to set isFolder to (class of item anAlias is folder)

You might also want to check if it’s a disk:

tell application "Finder" to set isDisk to (class of item anAlias is disk)

(OS9.2.2, AS1.6; OS10.2.2, AS1.9)