2

这是我正在尝试制作的脚本我正在尝试制作一个脚本来查看 Fido_Data 是否存在于我的桌面上,并带有 if 和 else 语句,但由于某种原因,它只是收到错误 Finder 出错:AppleEvent 处理程序失败。

tell application "Finder"
    if exists folder [homePath & "Desktop/Fido_Data"] then
        set FidoFolderExists to "yes"
    else
        display dialog homePath & "Desktop/"
        make new folder at [homePath & "Desktop/"] with properties {name:"Fido_Data"}
    end if
end tell
4

2 回答 2

1

尝试:

tell application "Finder"
    if exists folder ((path to desktop as text) & "Fido_Data") then
        set FidoFolderExists to "yes"
    else
        display dialog (path to desktop as text)
        make new folder at (path to desktop) with properties {name:"Fido_Data"}
    end if
end tell
于 2013-10-03T17:19:21.980 回答
1

我偶然发现在 10.10.5 中发现文件存在错误的间歇性案例。我建议:

-- ------------------------------------------------------  
(*
  Philip Regan
  https://stackoverflow.com/questions/3469389/applescript-testing-for-file-existence
*)
on fileExists(theFile) -- (String) as Boolean
    tell application "System Events"
        if exists file theFile then
            return true
        else
            return false
        end if
    end tell
end fileExists
于 2018-08-09T20:21:51.657 回答