2010-06-24 50 views
0

如果我有别名列表,我如何删除不是常规文件的列表或仅使用常规文件创建新列表。主要问题是如何确定别名是否是常规文件。我尝试了这个,但它很黑,它并不总是工作(如使用.app文件)。从AppleScript中的别名列表中仅获取常规文件

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

我该怎么做?

回答

1

您可以使用“种”属性的文件,以确定它是什么...

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 
0

这似乎有点哈克,但这似乎运作良好:

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 

我最初尝试在最后测试“:”的路径,但是它打破了捆绑应用程序和类似文件 - 这是真正的文件夹。