views:

16

answers:

2

If I have a list of aliases, how can I either remove the ones that are not regular files or create a new list with only regular files. The main question is how to determine if an alias is a regular file. I tried this, but it's hacky and it doesn't always work (like with .app files).

if (theFile as string) does not end with ":" then ...

How can I do this?

+1  A: 

You can use the "kind" property of a file to determine what it is...

set theFile to choose file
tell application "System Events"
    set theKind to kind of theFile
end tell

if theKind is not "Application" then
    return "Not an application"
else
    return "Is an application"
end if
regulus6633
A: 

It seems kind of hacky, but this seems to work well:

tell application "Finder"
    set regularFiles to {}
    repeat with theFile in theFiles
        if the URL of theFile does not end with "/"
            set end of regularFiles to theFile
        end if
    end repeat
end tell

I initially tried testing the path for a ":" at the end, but it breaks for bundled applications and similar files-which-are-really-folders.

Jeremy Cantrell