use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set {theResult, isExecutable} to theURL's getResourceValue:(reference) forKey:(current application's NSURLIsExecutableKey) |error|:(missing value)
if isExecutable as boolean then
-- whatever
end if
It appears that “.scpt” and “.applescript” files are not considered “executable” by the system. It seems like anything executable is named “.app”. So; I’ll still have to examine suffixes and filter out ones that are not to be processed.
By the way; the book is fantastic! I think it may have indicated a way to detect a particular file has actually been opened in it’s default app by using a notification handler. The standard loop-and-look-for-window-to-be-present is not working reliably. That “should” allow me to get the opened app windows to stack in the order of being “opened” by waiting for the current one to notify that it is ready for user input before initiating the next app. That will take a bit of experimentation. I’ve never seen anyone on the board do this before.