这是我想要制作的剧本 我正在尝试使用if和else语句创建一个脚本以查看我的桌面上是否存在Fido_Data但由于某种原因它只是得到错误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
答案 0 :(得分: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
答案 1 :(得分:1)
我偶然发现Finder在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