0
do shell script "mdfind kMDItemCFBundleIdentifier = com.test.sample > ~/Documents/sampleBuilds.txt"
set homeFolder to (path to home folder)
set sampleFiles to paragraphs of (read POSIX file (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))
        
if (count of sampleFiles) is 0 then
    display notification "No Sample builds are present on the system"
else
    set sampleFiles to paragraphs of (read POSIX file (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))                
    display dialog "You have " & (count of sampleFiles) & " build(s) of Sample on your system. Would you like to remove them all? This cannot be undone"

    repeat with c in SampleFiles
        do shell script "rm -rf " & (quoted form of c)
        display notification "Sample build located at " & c & " has been removed from your system"
    end repeat
            
    do shell script "rm -rf ~/Documents/SampleBuilds.txt"
end if

当使用正确的发件人将脚本放入 Xcode 时,我收到错误消息:

[AppDelegate testScript:]:无法将当前应用程序转换为类型文件。(错误-1700)就行了

将 sampleFiles 设置为(读取 POSIX 文件(homeFolder 的 POSIX 路径和“/Documents/sampleBuilds.txt”)的段落)

关于如何让 AppleScript 应用程序中的 Xcode 接受此脚本的任何想法?

4

1 回答 1

0

POSIX file不需要强制来解决问题。

set sampleFiles to paragraphs of (read (POSIX path of homeFolder & "/Documents/sampleBuilds.txt"))

基本上在 AppleScriptObjCPOSIX file foo中不起作用,您必须编写foo as POSIX file.

边注:

阅读文本两次是多余的。您可以删除第二set sampleFiles to ...行。

于 2017-07-27T04:05:47.777 回答