Re: easy way to check if item is file or folder
Re: easy way to check if item is file or folder
- Subject: Re: easy way to check if item is file or folder
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 20 Dec 2000 01:48:08 -0500
- Organization: [very little]
Erkki Pennanen wrote:
>
Date: Wed, 20 Dec 2000 05:45:29 +0200
>
To: email@hidden
>
From: Erkki Pennanen <email@hidden>
>
Subject: easy way to check if item is file or folder
>
>
I like to get an easy solution to check if the item is file or folder.
>
>
I have tried Scripting Standard addition4s Info for command, but the
>
folder property does not give expected result (true of false). Other
>
properties of Info for command seems to give correct results.
>
>
Made as follows:
>
>
set x to info for file "Macintosh HD:Desktop Folder:File_A"
>
locked of x
>
display dialog "Locked is:" & locked of x as text -- OK!
>
folder of
>
display dialog "Folder is:" & folder of x as text x -- does not work!
>
>
What4s wrong?
If you have access to the item, why don't you coerce it to text and
check the last character? If it's a ":", the item is a folder (or
volume). If it's not, it's a file.
set theFolder to (choose folder)
tell application "Finder" to set itemList to items of theFolder
repeat with anItem in itemList
set itemText to (contents of anItem) as text
if character -1 of itemText is ":" then
display dialog "It's a folder!"
else
display dialog "It's a file!"
end if
end repeat
Marc [12/20/00 1:47:19 AM]